3

我在angular-xeditable中使用了ui-select。在此示例中一切正常,但模型未更新(选择项目时 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>
4

1 回答 1

0

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

ui-select 支持: 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'); } });

于 2016-03-08T09:14:30.050 回答