marcoslin / angularAMD

Facilitate use of RequireJS in AngularJS
http://marcoslin.github.io/angularAMD
MIT License
734 stars 171 forks source link

Need more examples #136

Closed m-gora closed 9 years ago

m-gora commented 9 years ago

According to readme, module definitions end up in circular dependencies.

i think more examples would be helpful to understand how it really works.

in my particular case i have controller for the main page, that is always instantiated and a controller for each nested view. I was going to put the mainController into a seperate file, but then i end up with app requiring mainController and mainController requiring app.

putting controllers into files without deps to them wouldn't do anything, since nothing requires that controller.

same with directives. nav directive should be in the outer scope. so i would end up in a circular dep again.

marcoslin commented 9 years ago

"According to readme, module definitions end up in circular dependencies." -> Can you be a bit more specific here? I am not sure what are you referring to.

The way that angularAMD works is:

  1. Instantiate the app.js configure route using ngRoute or ui-route and bootstrap angularjs
  2. The default route would then load the defined controller on demand

For directives that could be used in controller or in app.js, you can create such directive using angularAMD instead of app as per Loading Application Wide Module

If this is still not clear, please provide some example of your code?