Search code examples
angularjsx-editableangular-ui-select

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


i used ui-select in angular-xeditable. in this sample all is ok but, Model not updated (foo.bar not change when select an item). can you help me?

<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>

Solution

  • I'm still testing, but After Many a cry and some prayers. The following modification works for me. got the idea from https://habrahabr.ru/post/277001/

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

    I've added 2 lines to the render function above code

    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'); } });