Currently in angular there no native support for lazy loading modules - you have to add them to html; and angular will wait for all js before starting execution.
> You might declare that module A depends on module B to make sure they get loaded in the right order, but that's the only reason for doing it. With 'ng-app' you chose what module is started as a 'root' of your application. With module dependency you can include other modules to that application - modules not included, can be load by the browser but are ignored by application. > You are not protected from situations where, for example, two modules declare a service with the same name. You are right, the name collisions can happen; it seems to me that in that case you will get what ever is declared closer to application root. Thats the reason why every where they recommend to user custom prefixed in directives; and why all internal angular services are prefixed with $. > You accidentally use <div id=foo> on two views and suddenly one of the views stops working—and if you're unlucky it isn't the one you just changed But this shall not happen. First angular doesn't care about your id, or classes in html - you use directives to bind view and behavior. In one application there will be always the same directive/controller/service used no mater how many name collisions you have - name will be always resolved in the same way. Other similar question could be: what if I have in two different part of my application: '<input ng-model="value">'? different parts of the page should be taken care of by different controllers. And if you have views managed by different controllers (even only different instances of the same controller the *value* will mean different thing in different places. 2014/1/25 Pete Chown <[email protected]> > Hello, > > I'm new to AngularJS and I'm confused about the way modules work. I would > expect (from other systems) that a module implementation would exist to > prevent namespace pollution. It might provide a way of exporting > functions, and importing required functions from other modules. It might > also control the order in which modules are loaded, so that if A depends on > B then B will be loaded before A. > > With AngularJS it seems different and that makes me think I may have > misunderstood. As I understand it, in AngularJS you are really supposed to > use dependency injection rather than exported symbols, and objects which > are eligible for injection do not have any kind of namespace. You might > declare that module A depends on module B to make sure they get loaded in > the right order, but that's the only reason for doing it. You are not > protected from situations where, for example, two modules declare a service > with the same name. > > Is my understanding correct? If so, is there a mechanism for preventing > these kinds of name clashes? I'm keen to use a framework like Angular > because otherwise, in a single page application, it's so easy to get > clashes of this kind. You accidentally use <div id=foo> on two views and > suddenly one of the views stops working—and if you're unlucky it isn't the > one you just changed. :-) > > Thank you for all your work developing Angular, it looks as though it will > be a good framework once I've figured out how it works! > > Pete > > -- > You received this message because you are subscribed to the Google Groups > "AngularJS" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at http://groups.google.com/group/angular. > For more options, visit https://groups.google.com/groups/opt_out. > -- You received this message because you are subscribed to the Google Groups "AngularJS" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/angular. For more options, visit https://groups.google.com/groups/opt_out.
