0

I get the following error:

TypeError: Cannot call method 'then' of undefined

on this code:

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')
}]);

I've been trying to follow these other examples of using promise within the controller (I'm not using $routeProvider), but nothing seems to be working.

AngularJS using $resource service. Promise is not resolved by GET request

AngularJS resource promise

Community
  • 1
  • 1
Steven Harlow
  • 631
  • 2
  • 11
  • 26

1 Answers1

0

@tymeJV provided this answer:

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

Steven Harlow
  • 631
  • 2
  • 11
  • 26