Error: Argument is not a function, got undefined

前端 未结 17 1889
不思量自难忘°
不思量自难忘° 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:15

    I have encountered the same problem and in my case it was happening as a result of this problem:

    I had the controllers defined in a separate module (called 'myApp.controllers') and injected to the main app module (called 'myApp') like this:

    angular.module('myApp', ['myApp.controllers'])
    

    A colleague pushed another controller module in a separate file but with the exact same name as mine (i.e. 'myApp.controllers' ) which caused this error. I think because Angular got confused between those controller modules. However the error message was not very helpful in discovering what is going wrong.

提交回复
热议问题