Bird87 ZA
Bird87 ZA

Reputation: 2160

Controller not defined AngularJS

I get this error when I try to run my application.

Argument 'CampaignsSettingsController' is not a function, got undefined

My controller is defined here:

// Called Second
var campaignsSettingsModule;
campaignsSettingsModule = angular.module('campaignsSettings');
campaignsSettingsModule.controller(
    'CampaignsSettingsController', [
        '$scope',
        '$window',
        'CampaignAdvancedSettings',
        function($scope, $window, CampaignAdvancedSettings) {
            // my controller code here
        }
    ]
);

And the campaignSettings module is called like this:

// Called first
var modules = ['evApp', 'campaignsSettings'];

for (var i = 0, length = modules.length; i < length; i++) {
    angular.module(modules[i], []).config(function($interpolateProvider){
        $interpolateProvider.startSymbol('{[').endSymbol(']}');
    });
}

The order in which these files are called (dunno if it makes a difference) is indicated above the code.

What would be the reason for getting the undefined error? Where can I start looking into solving this problem. I've read through various answers here, but I still can't get it fixed.

Upvotes: 1

Views: 1617

Answers (1)

Sajeetharan
Sajeetharan

Reputation: 222542

Change

From:

campaignsSettingsModule = angular.module('campaignsSettings');

To:

campaignsSettingsModule = angular.module('campaignsSettings',[]);

Upvotes: 2

Related Questions