Kilizo
Kilizo

Reputation: 3392

Dialog injecting a service

I have two controllers. One which handles the opening of a dialog and one which is the controller for the dialog itself.

Both controllers inject a service 'Directory', however on the dialog controller, the service is undefined.

Dialog Controller:

window.angular.module('tmo.controllers.directory', [])
    .controller('DirectoryController', ['$scope', 'Global', 'Directory',
        function ($scope, Global, number, Directory) {
            $scope.global = Global;
            $scope.direct = function (number) {
                Directory.direct(number);
            };
}]);

Returns:

TypeError: Cannot read property 'direct' of undefined

When I use the same method from the main controller (not the dialog), the Directory service is not undefined.

Upvotes: 0

Views: 55

Answers (1)

JB Nizet
JB Nizet

Reputation: 692231

The argument names of the controller are

'$scope', 'Global', 'Directory'

But the argument values are

$scope, Global, number, Directory

So the number argument actually contains the Directory, and the Directory argument is undefined.

Upvotes: 2

Related Questions