模型未在 angular-xeditable、angular Ui-Select 中更新

Model not update in angular-xeditable, angular Ui-Select

我用过ui-select in angular-xeditable。 在 this sample 中一切正常,但模型未更新(foo.bar 在 select 一个项目时未更改)。你能帮帮我吗?

<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

我在代码上方的渲染函数中添加了 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'); } });