i am currently investigating if it is necessary to define each dependency in my submodule either to define it in the main module. I will give you an example my purpose in a better way.
angular.module('mainApp', ['Restangular', 'mainApp.books']
My submodule "mainApp.books" which is responsible to manage your personal books also needs Restangular to work correctly. Since i have defined mainApp.books as dependency from my mainApp i don't need to specify Restangular in the submodule to get it work correctly.
angular.module('mainApp.books')....
Since the books module wouldn't ran as standalone application, i didn't need to specify the dependency of my submodule. How you handle this in your AngularJS projects? Hopefully i could describe my thoughts.
Thanks in advance.
You are doing the right thing, just what you say a submodule
is not really a submodule
, it is just a different module
.
all your modules require to use restangular
, so you can simply include dependency in your mainApp
module like you did in your example. and now you can use it inside the mainApp.books
module without specifying dependency for restangular
. This is exactly how dependecies are handled in angular. there is no need for creating dependency in each module or submodule.
The simple explanation would be, think of dependency as you are combining two modules together as a one large module, so no one would like to include dependency twice in the same module, isn't it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With