Reputation: 3444
I have pages with different Js and CSS in angularJS. So I need to load as per page. So what should I do.
etc.
for one page load two JS.
for second page load two JS.
for third page load one JS.
...
How to load JS as per page?
Upvotes: 0
Views: 112
Reputation: 41
If I understood correctly what you need is some kind of Lazy Loading. There are different ways to achieve this in AngularJS 1.x and from what I've heard Angular 2.x will provide its own way to lazy load.
Check this approach: https://egghead.io/lessons/angularjs-simple-lazy-loaded-angular-module-syntax-with-oclazyload
Upvotes: 1
Reputation: 3944
Yes you load javascript files asynchronously in other words ,you want lazy loading in your project,There are various methods to do it like: a.reqiurejs b.ocLazyLoad.js
please read this docs ,It may help you a lot
For ocLazyLoad.js:-https://oclazyload.readme.io/
For reqiurejs:-http://requirejs.org/docs/start.html I would personally prefre reqiurejs because it will handle dependecies very efficiently.
Upvotes: 1