0

我收到以下错误:

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 使用 $resource 服务。GET 请求未解决 Promise

AngularJS 资源承诺

4

1 回答 1

0

@tymeJV 提供了这个答案:

$scope.scope_variable = Main.query({}, function(result) { MainFilter.do_something(result) } );

于 2014-04-01T19:55:32.397 回答