angular/aio/content/examples/router/src/app/app-routing.module.6.ts
Alan Agius 8f389361ec docs: replace lazy loading import syntax parameter name (#34599)
We replace `mod` with `m` to be in line with what the CLI generates.

PR Close #34599
2020-01-07 10:44:12 -08:00

54 lines
1.3 KiB
TypeScript

// #docplaster
// #docregion, preload-v1
import { NgModule } from '@angular/core';
import {
RouterModule, Routes,
// #enddocregion preload-v1
PreloadAllModules
// #docregion preload-v1
} from '@angular/router';
import { ComposeMessageComponent } from './compose-message/compose-message.component';
import { PageNotFoundComponent } from './page-not-found/page-not-found.component';
import { AuthGuard } from './auth/auth.guard';
const appRoutes: Routes = [
{
path: 'compose',
component: ComposeMessageComponent,
outlet: 'popup'
},
{
path: 'admin',
loadChildren: () => import('./admin/admin.module').then(m => m.AdminModule),
canLoad: [AuthGuard]
},
{
path: 'crisis-center',
loadChildren: () => import('./crisis-center/crisis-center.module').then(m => m.CrisisCenterModule)
},
{ path: '', redirectTo: '/heroes', pathMatch: 'full' },
{ path: '**', component: PageNotFoundComponent }
];
@NgModule({
imports: [
// #docregion forRoot
RouterModule.forRoot(
appRoutes,
// #enddocregion preload-v1
{
enableTracing: true, // <-- debugging purposes only
preloadingStrategy: PreloadAllModules
}
// #docregion preload-v1
)
// #enddocregion forRoot
],
exports: [
RouterModule
]
})
export class AppRoutingModule {}