AngularJS seed: putting JavaScript into separate files (app.js, controllers.js, directives.js, filters.js, services.js)

后端 未结 3 1681
南笙
南笙 2020-12-12 13:16

I\'m using the angular-seed template to structure my application. Initially I put all my JavaScript code into a single file, main.js. This file contained my mod

3条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-12 14:09

    You get the error because you didn't define myApp.services yet. What I did so far is putting all the initial definitions in one file and then use them in another. Like for your example I would put in:

    app.js

    angular.module('myApp.services', []);
    
    angular.module('myApp', 
        ['myApp.services',
          ...]);
    

    That should get rid of the error, though I think you should have a read on the article Eduard Gamonal mentioned in one of the comments.

提交回复
热议问题