Loading…

How to enable lazy loading in angularjs?

With lazy loading, JS components can be loaded asynchronously on activation on a specific route.

  • Download and install ocLazyLoad.js
  • Add the module in the application
  • Load the file in the required controller
  • Add to the router’s code as

Example

                                        

resolve: {
     loadMyCtrl: ['$ocLazyLoad', function($ocLazyLoad) {return $ocLazyLoad.load('routerState');
}]}

Suggest An Answer

No suggestions avaliable!

Latest post from Angular 2 Interview Questions

Ask Question