AngularJS:后选项不触发

时间:2017-06-13 11:14:42

标签: angularjs multi-select

我正在使用带有angular-multiple-select 模块的angularjs版本1.6.4进行多选。一切都很好。我能够从建议中进行选择,但每当我选择"后选择项目"指令没有触发。根据angular-multiple-select模块文档

  

afterSelectItem:在添加项目之前侦听事件

<div class="form-group float-label-control">
      <label>Skills</label>
      <multiple-autocomplete ng-model="model.user.skills"
                             object-property="name"
                             after-select-item="model.afterSelectItem"
                             suggestions-arr="model.skills">
      </multiple-autocomplete>
</div>

我的控制器代码很少:

(function () {
    "use strict";

    var module = angular.module(__appName);
    function fetchSkills($http) {
    return $http.get(__apiRoot + "/skills")
            .then(function (response) {
                return response.data;
            })
}

function controller($http) {

    var model = this;

    model.$onInit = function () { 
        fetchSkills($http).then(function (skills) {
            model.skills = skills;
        });
    };

    model.afterSelectItem = function (item) {
        console.log("after select item");
        console.log(item);
    }
}

module.component("userEdit", {
    templateUrl: "components/user-edit/user-edit.template.html",
    bindings: {
        userId: "<",
        onUserSaved: "&"
    },
    controllerAs: "model",
    controller: ["$http", controller]
});

}());

0 个答案:

没有答案