1

Hello I can't call a factory function. When I use it I have the next message

enter image description here

Here my factory

enter image description here

And the controller with the call

enter image description here

When I try to print Account, it is undefined. Can anyone see my error? Thanks

David Luque
  • 1,078
  • 5
  • 18
  • 30

1 Answers1

3

It's because Account is not declared as a dependency of the controller. Change it to:

.controller('forgotController', ['$scope', '$location', 'Account',
                                 function($scope, $location, Account) {

For this to work, you need to make sure Account is available to the injector for your module. So when you declare the module that your controller is in, if it's not in the same module, be sure to include AccountService as a module dependency. For example:

angular.module('ForgotModule', ['AccountService'])
    .controller('forgotController', ['$scope', '$location', 'Account',
                                     function($scope, $location, Account) {
z0r
  • 8,185
  • 4
  • 64
  • 83