angular-cn/public/docs/_examples/router/ts/app/app-routing.module.ts

51 lines
1.3 KiB
TypeScript
Raw Normal View History

// #docplaster
// #docregion, preload-v1
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { ComposeMessageComponent } from './compose-message.component';
2016-12-21 12:08:39 -08:00
import { PageNotFoundComponent } from './not-found.component';
import { CanDeactivateGuard } from './can-deactivate-guard.service';
import { AuthGuard } from './auth-guard.service';
2016-12-21 12:08:39 -08:00
import { SelectivePreloadingStrategy } from './selective-preloading-strategy';
const appRoutes: Routes = [
{
path: 'compose',
component: ComposeMessageComponent,
2016-12-21 12:08:39 -08:00
outlet: 'popup'
},
{
path: 'admin',
loadChildren: 'app/admin/admin.module#AdminModule',
canLoad: [AuthGuard]
},
// #docregion preload-v2
{
path: 'crisis-center',
loadChildren: 'app/crisis-center/crisis-center.module#CrisisCenterModule',
2016-12-21 12:08:39 -08:00
data: { preload: true }
},
// #enddocregion preload-v2
2016-12-21 12:08:39 -08:00
{ path: '', redirectTo: '/heroes', pathMatch: 'full' },
{ path: '**', component: PageNotFoundComponent }
];
@NgModule({
imports: [
RouterModule.forRoot(
appRoutes,
2016-12-21 12:08:39 -08:00
{ preloadingStrategy: SelectivePreloadingStrategy }
)
],
exports: [
RouterModule
],
providers: [
CanDeactivateGuard,
2016-12-21 12:08:39 -08:00
SelectivePreloadingStrategy
]
})
export class AppRoutingModule {}