0

I'm working on an AngularJS app and just getting started. When I run the app I get in the console

'Argument 'MassPartMaintController' is not a function, got undefined'

Here is what my controller looks like

+function() {
  function MassPartMaintController() {
    var ctrl = this;
    ctrl.uploadSectionTitle = 'Upload';
  }
  angular.module('MassPartMaint').controller('MassPartMaintController', [MassPartMaintController]);
}();

I copied the structure of the controller from another project that is working, so I can't figure out what the issue is here.

I do find the +function() syntax weird, but it works fine in other projects. Does anyone have any ideas on what the issue is?

Aleksey Solovey
  • 4,153
  • 3
  • 15
  • 34
HarvP
  • 190
  • 3
  • 13
  • It seems that the only plausible way this could happen is if `MassPartMaintController` is actually `undefined`, which would not be possible in the code you've shown us. Are you showing us the actual code you're using? – JLRishe Oct 08 '20 at 18:50
  • Does this answer your question? [Module is not available, misspelled or forgot to load (but I didn't)](https://stackoverflow.com/questions/31394850/module-is-not-available-misspelled-or-forgot-to-load-but-i-didnt) – m90 Oct 08 '20 at 18:50
  • When declaring a module for the first time, you will need to specify its dependencies, even if none are needed. Without passing dependencies, you will try to reference a module that has already been defined. I.e. your code needs to be `angular.module('MassPartMaint', []).controller('MassPartMaintController', [MassPartMaintController]);` – m90 Oct 08 '20 at 18:52

0 Answers0