【发布时间】:2015-06-23 16:29:03
【问题描述】:
当我在第 5 行 console.log(result) 时,它返回就好了。第 11 行的 console.log($scope.notes) 返回 undefined。有什么想法吗?
这是我的控制器:
$scope.$watchCollection = (['parent_id', 'parent_type'], function(){
$scope.loadNotes = function(){
$http.get('/api/notes/' + $scope.parent_id + "/" + $scope.parent_type).success(function(result){
console.log(result);
$scope.notes = result;
return result;
});
}
$scope.notes = $scope.loadNotes();
console.log($scope.notes);
});
【问题讨论】:
-
Schw2iizer,我已经发布了答案,是否消除了您的疑问并给出了答案?
-
好的,非常感谢。
标签: angularjs ng-repeat ng-init