“md-chips-select”不绑定来自http请求的数据

时间:2015-10-26 13:35:01

标签: angularjs md-chip

我在项目中使用了“md-chips-select”npm模块。当我绑定静态数据时,它正常工作,如:

$scope.listItems = [{ name: "Mini Cooper", id: 0 }, { name: "Lexus IS250", id: 1 }, { name: "Ford F150", id: 2 }, { name: "Toyota Prius", id: 3 }];






<md-chips-select ng-model="selectedItems" select-items="listItems" main-title="name"></md-chips-select>

但是当我从http请求加载数据时,它无法正常工作。

$scope.listItems = [];
        Section.get()
            .success(function(data) {
                if(data){
                        _.each(data ,function (_jsonObject) {
                            var _c = _jsonObject.Class + "-" + _jsonObject.Section;
                            var _json = { name : _c, id : _jsonObject._id };
                            $scope.listItems.push(_json);
                        });
                    }
                });

0 个答案:

没有答案