2

I'm trying to find a tool or a .js lib to lazy load my scripts on demand of the routes/urls'.

Basically, I want to:

state = {
  state: 'widgets',
  config: {
     url: '/',
     templateUrl: 'modules/widgets/templates/widgets.template.html',
     resolve: {
         // load the .js  somehow
     }          
}
$stateProvider.state(state.state, state.config);

have anyone already done that? or is there a stand for lazy load .js files?

Thanks!

2 Answers 2

1

Probably not exactly what you need, but yes, you can use $controllerProvider. you can find a very nice article here that explains lazy loading in angular - http://ify.io/lazy-loading-in-angularjs/

check this out - AngularJS: lazy loading controllers and content and the lazy load library https://oclazyload.readme.io/

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks! It's a good start!
1

You can use UI-Router Extras Future States https://christopherthielen.github.io/ui-router-extras/#/future

There is a yeoman generator: https://github.com/matoilic/generator-angular-lazy which can get you started quickly with ocLazyLoad + Future States

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.