- To take advantage of route preloading, we first have to turn it on in our root router configuration. By default, the Angular router comes with one of two preloading strategies; preload everything with PreloadAllModules, or preload nothing with NoPreloading:
...import {RouterModule, PreloadAllModules} from '@angular/router';@NgModule({ ... imports: [ BrowserModule, FormsModule, HttpModule, RouterModule.forRoot(ROUTES, { preloadingStrategy: PreloadAllModules }) ], ...})export class AppModule { }
- Now that we have enabled preloading on our root router configuration, we have to enable lazy loading modules. For our router configuration, we must provide our lazy loaded child module in a string format using the loadChildren property. ...