Error: Argument is not a function, got undefined

前端 未结 17 1844
不思量自难忘°
不思量自难忘° 2020-12-07 19:35

Using AngularJS with Scala Play, I\'m getting this error.

Error: Argument \'MainCtrl\' is not a function, got undefined

I\'m try

17条回答
  •  一生所求
    2020-12-07 20:14

    I had the same error message (in my case : "Argument 'languageSelectorCtrl' is not a function, got undefined").

    After some tedious comparison with Angular seed's code, I found out that I had previously removed a reference to the controllers module in app.js. (spot it at https://github.com/angular/angular-seed/blob/master/app/js/app.js)

    So I had this:

    angular.module('MyApp', ['MyApp.filters', 'MyApp.services', 'MyApp.directives'])

    This failed.

    And when I added the missing reference:

    angular.module('MyApp', ['MyApp.filters', 'MyApp.services', 'MyApp.controllers', 'MyApp.directives'])

    The error message disappeared and Angular could instanciate the controllers again.

提交回复
热议问题