필터를 사용하여 리피터에서 ID를 추출하고 있습니다. 그것은 모두 잘 작동하지만 콘솔에서 나는 다음과 같은 오류가 점점 오전 :
https://docs.angularjs.org/error/$interpolate/interr?p0=%7B%7BspecsList%20%7C%20splitIds%7D%7D&p1=TypeError:%20Cannot%20read%20property%20%27map%27%20of%20undefined
내가 specsList정적 값으로 $http.get
를 교체 할 경우, 오류가 없습니다. 좋은 방법으로 그 문제를 해결하는 방법에 대한 아이디어가 있습니까?
JS :
app.controller('SpecsController', function ($scope, $http) {
$scope.$on('$viewContentLoaded', function(event) {
$http.get('getSpecs.aspx')
.then(function(result) {
$scope.specsList = result.data.specs;
})
.catch(function(err) {
console.log(err);
});
});
$scope.sortableOptions = {
handle: "> .position",
helper: function (e, ui) {
var originals = ui.children();
var clonedHelper = ui.clone();
clonedHelper.children().each(function(index) {
//$(this).width($(this).width());
$(this).width(originals.eq(index).outerWidth());
$(this).addClass("dragging");
$(this).parent().addClass("dragging_tr");
});
return clonedHelper;
},
update: function(e, ui) {
//console.log("update");
},
stop: function(e, ui) {
//Save sortorder
}
};
});
app.filter('splitIds', function() {
return function(ArrayWithIds) {
return ArrayWithIds.map(function(item){return item.id;}).join();
};
});
HTML : 약속이 반환되고
<input type="text" value="{{specsList | splitIds}}" />
감사합니다. 정말 감사합니다! – peta