docs(router): Fixed lazy loading initial example

closes #2070
This commit is contained in:
Brandon Roberts 2016-08-09 19:10:19 -05:00 committed by Ward Bell
parent 162b1773be
commit 420b9ca59e
4 changed files with 49 additions and 13 deletions

View File

@ -0,0 +1,46 @@
// #docregion
// #docregion import-router
import { Routes, RouterModule } from '@angular/router';
// #enddocregion import-router
import { loginRoutes,
authProviders } from './login.routing';
import { CanDeactivateGuard } from './can-deactivate-guard.service';
// #docregion lazy-load-crisis-center
const crisisCenterRoutes: Routes = [
{
path: '',
redirectTo: '/crisis-center',
pathMatch: 'full'
},
{
path: 'crisis-center',
loadChildren: 'app/crisis-center/crisis-center.module#CrisisCenterModule'
}
];
const appRoutes: Routes = [
...loginRoutes,
...crisisCenterRoutes
];
// #enddocregion lazy-load-crisis-center
export const appRoutingProviders: any[] = [
authProviders,
CanDeactivateGuard
];
export const routing = RouterModule.forRoot(appRoutes);
// #enddocregion
/* A link parameters array
// #docregion heroes-redirect
{
path: '',
redirectTo: '/heroes',
pathMatch: 'full'
},
// #enddocregion heroes-redirect
*/

View File

@ -33,13 +33,3 @@ export const appRoutingProviders: any[] = [
];
export const routing = RouterModule.forRoot(appRoutes);
/* A link parameters array
// #docregion heroes-redirect
{
path: '',
redirectTo: '/heroes',
pathMatch: 'full'
},
// #enddocregion heroes-redirect
*/

View File

@ -3,7 +3,7 @@
"files":[
"!**/*.d.ts",
"!**/*.js",
"!**/*.[1,2,3,4,5].*",
"!**/*.[1,2,3,4,5,6].*",
"!app/crisis-list.component.ts",
"!app/hero-list.component.ts",
"!app/crisis-center/add-crisis.component.ts",

View File

@ -1687,7 +1687,7 @@ figure.image-display
our child routes.
+makeTabs(
`router/ts/app/app.routing.ts,
`router/ts/app/app.routing.6.ts,
router/ts/app/crisis-center/crisis-center.routing.ts`,
'lazy-load-crisis-center,lazy-load-crisis-center',
`app.routing.ts (load children),
@ -1725,7 +1725,7 @@ figure.image-display
If our initial redirect went to `/heroes` instead of going to `/crisis-center`, the `CrisisCenterModule` would not be loaded until the user
visited a `Crisis Center` route. We'll update our redirect in our `app.routing.ts` to make this change.
+makeExample('router/ts/app/app.routing.ts', 'heroes-redirect', 'app.routing.ts (heroes redirect)')
+makeExample('router/ts/app/app.routing.6.ts', 'heroes-redirect', 'app.routing.ts (heroes redirect)')
<a id="final-app"></a>
.l-main-section