模型不会以角度可修改的角度进行更新,角度Ui-Select

时间:2015-11-05 08:57:33

标签: angularjs x-editable angular-ui-select

我在ui-select中使用了angular-xeditable。 在this sample中一切正常但是,模型未更新(选择项目时foo.bar不会更改)。你能救我吗?

<span editable-ui-select="foo.bar" e-ng-model="foo.bar" e-name="bar" name="bar" e-form="editableForm">
      {{foo.bar.name}}
      <editable-ui-select-match placeholder="Search..." style="width:500px">
        {{$select.selected.name}}
      </editable-ui-select-match>
      <editable-ui-select-choices repeat="b in bars | filter:$select.search">
        {{b.name}}
      </editable-ui-select-choices>
    </span>

1 个答案:

答案 0 :(得分:0)

我还在测试,但经过多次哭泣和一些祈祷。以下修改对我有用。从https://habrahabr.ru/post/277001/

得到了这个想法

ui-select support https://github.com/vitalets/angular-xeditable/pull/300/files#diff-90635473805044e26bceb2f7ffecfa82

我在代码

上面的渲染函数中添加了2行
this.inputEl.attr('on-select', 'fooEvent($item)');
this.inputEl.attr('ng-model', '$parent.$data');

var dir = editableDirectiveFactory({ directiveName: 'editableUiSelect', inputTpl: '<ui-select></ui-select>', render: function () { this.parent.render.call(this); this.inputEl.append(rename('ui-select-match', match)); this.inputEl.append(rename('ui-select-choices', choices)); this.inputEl.attr('on-select', 'fooEvent($item)'); this.inputEl.attr('ng-model', '$parent.$data'); } });

相关问题