In the current version (1.0.4 and 1.1.2), AngularJS will not execute any JavaScript code contained in partial, specified via templateUrl (or template ).
At the moment, your best bet is to pre-load most of the code up. People have been experimenting with requireJS, and there are many questions about this on SO and on the mailing list. But the truth is that - on-demand loading can be done for controllers and particulars - in general, on-demand loading is poorly supported (see How does modularity soften in AngularJS? For more information on this). In practice, this may not be a problem, since code written using AngularJS tends to be really, very concise, so preloading things ahead has no adverse performance consequences (on the contrary, since all the code is in the browser, there are no delays associated with load on request).
On-demand loading is a function that is processed as part of AngularJS 2.0.
pkozlowski.opensource
source share