[Angular 8] Custom Route Preloading with ngx-quicklink and A
发布时间:2020-12-17 07:06:36 所属栏目:安全 来源:网络整理
导读:In a?previous lesson we learned about implementing a custom preloading strategy. That gives you a lot of control over which route to preload and which not,whether it is based on the user‘s permissions or some runtime app config. In this l
In a?previous lesson we learned about implementing a custom preloading strategy. That gives you a lot of control over which route to preload and which not,whether it is based on the user‘s permissions or some runtime app config. In this lesson we‘re using?ngx-quicklink,a library that drastically simplifies the custom preloading,by automatically loading all visible links on the page. ? Install: npm install --save ngx-quicklink ? Load the module: import { QuicklinkStrategy,QuicklinkModule } from ‘ngx-quicklink‘; @NgModule({ declarations: [AppComponent,HomeComponent],imports: [ BrowserModule,MatSidenavModule,BrowserAnimationsModule,QuicklinkModule,RouterModule.forRoot( [ { path: ‘‘,component: HomeComponent },{ path: ‘nyan‘,loadChildren: () => import(‘./nyan/nyan.module‘).then(m => m.NyanModule) },{ path: ‘about‘,loadChildren: () => import(‘./about/about.module‘).then(m => m.AboutModule) } ],{ preloadingStrategy: QuicklinkStrategy //PreloadAllModules } ) ],providers: [],bootstrap: [AppComponent] }) (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |