This is the archived documentation for Angular v5. Please visit angular.io to see documentation for the current version of Angular.

RouterPreloader

npm Package @angular/router
Module import { RouterPreloader } from '@angular/router';
Source router/src/router_preloader.ts

Overview

      
      class RouterPreloader implements OnDestroy {
  constructor(router: Router, moduleLoader: NgModuleFactoryLoader, compiler: Compiler, injector: Injector, preloadingStrategy: PreloadingStrategy)
  setUpPreloading(): void
  preload(): Observable<any>
  ngOnDestroy(): void
}
    

Description

The preloader optimistically loads all router configurations to make navigations into lazily-loaded sections of the application faster.

The preloader runs in the background. When the router bootstraps, the preloader starts listening to all navigation events. After every such event, the preloader will check if any configurations can be loaded lazily.

If a route is protected by canLoad guards, the preloaded will not load it.

Constructor

      
      constructor(router: Router, moduleLoader: NgModuleFactoryLoader, compiler: Compiler, injector: Injector, preloadingStrategy: PreloadingStrategy)
    

Members

      
      setUpPreloading(): void
    

      
      preload(): Observable<any>
    

      
      ngOnDestroy(): void
    

Annotations

      
      @Injectable()