我收到以下错误:
TypeError: Cannot call method 'then' of undefined
关于此代码:
App.controller('MainCtrl', ['$scope', 'Main', 'MainFilter', function($scope, Main, MainFilter) {
$scope.scope_variable = Main.query().$promise.then( function(result) { MainFilter.do_something(result) } );
}]);
App.factory('Main', ['$resource', function($resource) {
return $resource('/main_resource.json')
}]);
我一直在尝试遵循在控制器中使用promise的其他示例(我没有使用$ routeProvider),但似乎没有任何工作。
AngularJS using $resource service. Promise is not resolved by GET request
答案 0 :(得分:0)
@tymeJV提供了这个答案:
$ scope.scope_variable = Main.query({},function(result){MainFilter.do_something(result)});