我正在尝试将对象从函数返回到 ng-repeat:
<ul ng-controller="Users" ng-repeat="user in users">
<li ng-controller="Albums" ng-repeat="album in getAlbumList(user.name)">
{{album.title}}
</li>
</ul>
.controller('Albums', ['$scope','Imgur', function($scope, Imgur) {
$scope.getAlbumList = function(user) {
Imgur.albumList.get({user:user},
function(value) {
return value.data;
console.log('success');
},
function(error) {
console.log('something went wrong');
}
);
}
}]);
.factory('Imgur', function($resource, $http) {
return {
albumList : $resource('https://api.imgur.com/3/account/:user/albums'),
album : $resource('https://api.imgur.com/3/account/:user/album/:id')
}
});
然而,这种方法在每次页面加载时都会使我的浏览器崩溃。
这样做的正确方法是什么?