1

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.

4
  • Check with this checklist:stackoverflow.com/a/26797874/930170 Commented Jul 29, 2016 at 8:04
  • As far as I am always doing custom modules are always injected on the second of param of angular.module('thisModuleName', ['inject', 'your', 'modules', 'here']) also, dont wrap it in for loop. It looks weird. Commented Jul 29, 2016 at 8:09
  • By the way I wrote a personal template/boiler plate for angularjs this might help you construct your angular project easier. Here. github.com/jofftiquez/angular-app-starter-pack Commented Jul 29, 2016 at 8:13
  • Seems like a dumb question, but have you remembered to include the JS file on your index file? Commented Jul 29, 2016 at 8:19

1 Answer 1

2

Change

From:

campaignsSettingsModule = angular.module('campaignsSettings');

To:

campaignsSettingsModule = angular.module('campaignsSettings',[]);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.