Angularjs: Error: [ng:areq] Argument 'HomeController' is not a function, got undefined

前端 未结 24 1606
抹茶落季
抹茶落季 2020-11-27 12:22

This is my demo using angularjs, for creating a service file, and adding service to a controller.

I have two problems with my demo:

  • One is when I put <
24条回答
  •  日久生厌
    2020-11-27 12:44

    Obviously that previous posts are useful, but any of above are not helpful in my case. The reason was in wrong sequence of loading scripts. For example, in my case, controller editCtrl.js depends on (uses) ui-bootstrap-tpls.js, so it should be loaded first. This caused an error:

    
    
    

    This is right, works:

    
    
    

    So, to fix the error you need first declare all scripts without dependencies, and then scripts that depends on previously declared.

提交回复
热议问题