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
BY Best Interview Question ON 07 Apr 2020
Example
resolve: {
loadMyCtrl: ['$ocLazyLoad', function($ocLazyLoad) {return $ocLazyLoad.load('routerState');
}]}