【发布时间】:2014-12-11 10:28:54
【问题描述】:
我想在我的应用程序上使用 angular sortable。但是我的模型是从几个带有$http.get() 函数的json文件动态填充的。 ngSortable 从模型中看到的只是一个空数组。而且它不会从 JSON 文件中获取新数据。有什么解决方法吗?
$scope.jsons = ["data1.json", "data2.json"];
$scope.abc = [];
angular.forEach($scope.jsons, function(value, key){
$http.get(value).success (function(data){
$scope.abc.push(data);
});
});
$scope.sortableOptions = {
accept: function (sourceItemHandleScope, destSortableScope) {return true}
};
<div ng-model="abc" as-sortable="sortableOptions">
<div ng-repeat="x in abc" as-sortable-item>
<div as-sortable-item-handle>{{x.name}}</div>
</div>
</div>
【问题讨论】: