Saturday, 15 March 2014

javascript - How to fix an angular.module not working with dependent modules? -


I'm very clear on how angular.module works but it eludes me for whatever reason.

I have the following in my code

  var app = angular The module ("myApp", []) app.controller ("MainCtrl", ...)  

but my code works only when there is no array for dependent modules Is, like:

  var app = angular Module ("myApp"); App.controller ("MainCtrl", ...)  

I do not have any clue what would be the cause of the problem, because I have always understood the need for empty array.

I have always understood the need for empty arrays

ARA is required only in the form of a second argument when the module is created. Then

you create new modules with

  angular.module ("myApp", []). And  
  angular. With the module ("myApp")  

you have regained the pre-existing module that was previously created.

My code works only when there is no array for dependable modules

This means that you already have module myApp created in this case you do not have to make it again again, because it will erase the registered registrars etc.


No comments:

Post a Comment