Skip to content
This repository was archived by the owner on Dec 4, 2017. It is now read-only.

Commit a74f8fb

Browse files
brandonrobertswardbell
authored andcommitted
docs(router): Added wildcard route to live example (#2897)
1 parent 2717dfb commit a74f8fb

19 files changed

+127
-33
lines changed

public/docs/_examples/router/e2e-spec.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ describe('Router', function () {
3131
loginHref: hrefEles.get(3),
3232
loginButton: element.all(by.css('my-app > ng-component > p > button')),
3333

34+
sidekicksButton: element.all(by.css('my-app > ng-component > button')),
35+
3436
};
3537
}
3638

@@ -118,6 +120,15 @@ describe('Router', function () {
118120
});
119121
});
120122

123+
it('should be able to handle 404 pages', function () {
124+
let page = getPageStruct();
125+
page.heroesHref.click().then(function() {
126+
return page.sidekicksButton.click();
127+
}).then(function() {
128+
expect(page.routerTitle.getText()).toContain('Page Not Found');
129+
});
130+
});
131+
121132
function crisisCenterEdit(index: number, shouldSave: boolean) {
122133
let page = getPageStruct();
123134
let crisisEle: ElementFinder;

public/docs/_examples/router/ts/app/app-routing.module.1.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@ import { RouterModule, Routes } from '@angular/router';
55

66
import { CrisisListComponent } from './crisis-list.component';
77
import { HeroListComponent } from './hero-list.component';
8+
import { PageNotFoundComponent }from './not-found.component';
89

910
const appRoutes: Routes = [
1011
{ path: 'crisis-center', component: CrisisListComponent },
11-
{ path: 'heroes', component: HeroListComponent }
12+
{ path: 'heroes', component: HeroListComponent },
13+
{ path: '**', component: PageNotFoundComponent }
1214
];
1315

1416
@NgModule({

public/docs/_examples/router/ts/app/app-routing.module.2.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@ import { NgModule } from '@angular/core';
44
import { RouterModule, Routes } from '@angular/router';
55

66
import { CrisisListComponent } from './crisis-list.component';
7+
import { PageNotFoundComponent }from './not-found.component';
78

89
const appRoutes: Routes = [
9-
{ path: 'crisis-center', component: CrisisListComponent }
10+
{ path: 'crisis-center', component: CrisisListComponent },
11+
{ path: '**', component: PageNotFoundComponent }
1012
];
1113

1214
@NgModule({

public/docs/_examples/router/ts/app/app-routing.module.3.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
// #docplaster
22
// #docregion
3-
import { NgModule } from '@angular/core';
3+
import { NgModule } from '@angular/core';
44
import { RouterModule, Routes } from '@angular/router';
5+
import { PageNotFoundComponent }from './not-found.component';
56

67
const appRoutes: Routes = [
7-
8+
{ path: '**', component: PageNotFoundComponent }
89
];
910

1011
@NgModule({

public/docs/_examples/router/ts/app/app-routing.module.4.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@
22
// #docregion
33
import { NgModule } from '@angular/core';
44
import { RouterModule, Routes } from '@angular/router';
5+
import { PageNotFoundComponent }from './not-found.component';
56

67
import { CanDeactivateGuard } from './can-deactivate-guard.service';
78

89
const appRoutes: Routes = [
9-
10+
{ path: '**', component: PageNotFoundComponent }
1011
];
1112

1213
@NgModule({

public/docs/_examples/router/ts/app/app-routing.module.5.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import { NgModule } from '@angular/core';
44
// #docregion import-router
55
import { RouterModule, Routes } from '@angular/router';
66
// #enddocregion import-router
7-
8-
import { CanDeactivateGuard } from './can-deactivate-guard.service';
7+
import { PageNotFoundComponent } from './not-found.component';
8+
import { CanDeactivateGuard } from './can-deactivate-guard.service';
99
// #docregion can-load-guard
1010
import { AuthGuard } from './auth-guard.service';
1111
// #enddocregion can-load-guard
@@ -19,7 +19,8 @@ const appRoutes: Routes = [
1919
// #enddocregion lazy-load-admin
2020
canLoad: [AuthGuard]
2121
// #docregion lazy-load-admin
22-
}
22+
},
23+
{ path: '**', component: PageNotFoundComponent }
2324
];
2425

2526
@NgModule({

public/docs/_examples/router/ts/app/app-routing.module.6.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ import {
88
// #docregion preload-v1
99
} from '@angular/router';
1010

11-
import { CanDeactivateGuard } from './can-deactivate-guard.service';
12-
import { AuthGuard } from './auth-guard.service';
11+
import { PageNotFoundComponent } from './not-found.component';
12+
import { CanDeactivateGuard } from './can-deactivate-guard.service';
13+
import { AuthGuard } from './auth-guard.service';
1314

1415
const appRoutes: Routes = [
1516
{
@@ -25,7 +26,8 @@ const appRoutes: Routes = [
2526
{
2627
path: 'crisis-center',
2728
loadChildren: 'app/crisis-center/crisis-center.module#CrisisCenterModule'
28-
}
29+
},
30+
{ path: '**', component: PageNotFoundComponent }
2931
];
3032

3133
@NgModule({

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
import { NgModule } from '@angular/core';
44
import { RouterModule, Routes } from '@angular/router';
55

6-
import { CanDeactivateGuard } from './can-deactivate-guard.service';
7-
import { AuthGuard } from './auth-guard.service';
6+
import { PageNotFoundComponent } from './not-found.component';
7+
import { CanDeactivateGuard } from './can-deactivate-guard.service';
8+
import { AuthGuard } from './auth-guard.service';
89
import { PreloadSelectedModules } from './selective-preload-strategy';
910

1011
const appRoutes: Routes = [
@@ -25,6 +26,10 @@ const appRoutes: Routes = [
2526
data: {
2627
preload: true
2728
}
29+
},
30+
{
31+
path: '**',
32+
component: PageNotFoundComponent
2833
}
2934
// #enddocregion preload-v2
3035
];
Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,27 @@
11
// #docplaster
22
// #docregion
3+
// #docregion first-config
34
import { NgModule } from '@angular/core';
45
import { BrowserModule } from '@angular/platform-browser';
56
import { FormsModule } from '@angular/forms';
6-
// #docregion import-router, route-config
7+
// #docregion import-router
78
import { RouterModule, Routes } from '@angular/router';
8-
// #enddocregion import-router, route-config
9+
// #enddocregion import-router
910

10-
// #docregion router-basics
1111
import { AppComponent } from './app.component';
1212
import { CrisisListComponent } from './crisis-list.component';
1313
import { HeroListComponent } from './hero-list.component';
14+
// #enddocregion first-config
15+
import { PageNotFoundComponent }from './not-found.component';
16+
// #docregion first-config
1417

15-
// #docregion route-config
1618
const appRoutes: Routes = [
1719
{ path: 'crisis-center', component: CrisisListComponent },
18-
{ path: 'heroes', component: HeroListComponent }
20+
{ path: 'heroes', component: HeroListComponent },
21+
// #enddocregion first-config
22+
{ path: '**', component: PageNotFoundComponent }
23+
// #docregion first-config
1924
];
20-
// #enddocregion route-config
2125

2226
@NgModule({
2327
imports: [
@@ -28,11 +32,13 @@ const appRoutes: Routes = [
2832
declarations: [
2933
AppComponent,
3034
HeroListComponent,
31-
CrisisListComponent
35+
CrisisListComponent,
36+
// #enddocregion first-config
37+
PageNotFoundComponent
38+
// #docregion first-config
3239
],
3340
bootstrap: [ AppComponent ]
3441
})
35-
// #enddocregion router-basics
3642
export class AppModule {
3743
}
3844
// #enddocregion

public/docs/_examples/router/ts/app/app.module.2.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { AppRoutingModule } from './app-routing.module';
1010

1111
import { CrisisListComponent } from './crisis-list.component';
1212
import { HeroListComponent } from './hero-list.component';
13+
import { PageNotFoundComponent }from './not-found.component';
1314

1415
@NgModule({
1516
imports: [
@@ -20,7 +21,8 @@ import { HeroListComponent } from './hero-list.component';
2021
declarations: [
2122
AppComponent,
2223
HeroListComponent,
23-
CrisisListComponent
24+
CrisisListComponent,
25+
PageNotFoundComponent
2426
],
2527
bootstrap: [ AppComponent ]
2628
})

0 commit comments

Comments
 (0)