我在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>
最佳答案
我仍在测试中,但经过一阵子的哭泣和祈祷。以下修改对我有效。是从https://habrahabr.ru/post/277001/得到的主意
ui-select支持:
https://github.com/vitalets/angular-xeditable/pull/300/files#diff-90635473805044e26bceb2f7ffecfa82
我在代码上方的render函数中添加了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'); } });
关于angularjs - 无法在可编辑 Angular 的 Angular Ui-Select中更新模型,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/33540207/