ciochPep
ciochPep

Reputation: 2592

Angular.js: script tags in partial page?

We are writing an angular.js+require.js app...

Is it possible to load require.js modules in a lazy manner upon loading of a partial page?

Upvotes: 1

Views: 1074

Answers (1)

pkozlowski.opensource
pkozlowski.opensource

Reputation: 117370

With the current version of AngularJS (1.x) all the modules need to be loaded up-front so it is not possible to load them on demand (this is something that is probably going to change in the next version).

What you can load on-demand today are partials and globally defined controllers. People were experimenting with different approaches for using require.js and AngularJS, this question has more info.

Having said the above usually code written with AngularJS is extremely concise as compared to other frameworks. As such it can be safely downloaded up-front (some really large applications use this approach). So I would advice against putting require.js up-front.

Upvotes: 3

Related Questions