import { of, Observable } from 'rxjs'; import { PreloadingStrategy, Route } from '@angular/router'; import { Injectable } from '@angular/core'; @Injectable({ providedIn: 'root' }) export class NaSelectivePreloadStrategy implements PreloadingStrategy { preloadedModules: string[] = []; preload(route: Route, load: Function): Observable { if (route.data && route.data['preload']) { // add the route path to our preloaded module array this.preloadedModules.push(route.path); // log the route path to the console // console.log('Preloaded: ' + route.path); return load(); } else { return of(null); } } }