diff --git a/aio/content/examples/router/e2e/src/app.e2e-spec.ts b/aio/content/examples/router/e2e/src/app.e2e-spec.ts index 89adb2efab..41d3a49c9a 100644 --- a/aio/content/examples/router/e2e/src/app.e2e-spec.ts +++ b/aio/content/examples/router/e2e/src/app.e2e-spec.ts @@ -4,7 +4,7 @@ import { browser, element, by, ExpectedConditions } from 'protractor'; const numDashboardTabs = 5; const numCrises = 4; -const numHeroes = 6; +const numHeroes = 10; const EC = ExpectedConditions; describe('Router', () => { @@ -13,34 +13,34 @@ describe('Router', () => { function getPageStruct() { const hrefEles = element.all(by.css('app-root > nav a')); - const crisisDetail = element.all(by.css('app-root > div > ng-component > ng-component > ng-component > div')).first(); - const heroDetail = element(by.css('app-root > div > ng-component')); + const crisisDetail = element.all(by.css('app-root > div > app-crisis-center > app-crisis-list > app-crisis-detail > div')).first(); + const heroDetail = element(by.css('app-root > div > app-hero-detail')); return { hrefs: hrefEles, activeHref: element(by.css('app-root > nav a.active')), crisisHref: hrefEles.get(0), - crisisList: element.all(by.css('app-root > div > ng-component > ng-component li')), + crisisList: element.all(by.css('app-root > div > app-crisis-center > app-crisis-list li')), crisisDetail: crisisDetail, crisisDetailTitle: crisisDetail.element(by.xpath('*[1]')), heroesHref: hrefEles.get(1), - heroesList: element.all(by.css('app-root > div > ng-component li')), + heroesList: element.all(by.css('app-root > div > app-hero-list li')), heroDetail: heroDetail, heroDetailTitle: heroDetail.element(by.xpath('*[2]')), adminHref: hrefEles.get(2), - adminPreloadList: element.all(by.css('app-root > div > ng-component > ng-component > ul > li')), + adminPreloadList: element.all(by.css('app-root > div > app-admin > app-admin-dashboard > ul > li')), loginHref: hrefEles.get(3), - loginButton: element.all(by.css('app-root > div > ng-component > p > button')), + loginButton: element.all(by.css('app-root > div > app-login > p > button')), contactHref: hrefEles.get(4), contactCancelButton: element.all(by.buttonText('Cancel')), - primaryOutlet: element.all(by.css('app-root > div > ng-component')), - secondaryOutlet: element.all(by.css('app-root > ng-component')) + primaryOutlet: element.all(by.css('app-root > div > app-hero-list')), + secondaryOutlet: element.all(by.css('app-root > app-compose-message')) }; } diff --git a/aio/content/examples/router/src/app/admin/admin-dashboard.component.1.ts b/aio/content/examples/router/src/app/admin/admin-dashboard.component.1.ts deleted file mode 100644 index ffa3e3cb8f..0000000000 --- a/aio/content/examples/router/src/app/admin/admin-dashboard.component.1.ts +++ /dev/null @@ -1,9 +0,0 @@ -// #docregion -import { Component } from '@angular/core'; - -@Component({ - template: ` -
Dashboard
- ` -}) -export class AdminDashboardComponent { } diff --git a/aio/content/examples/router/src/app/admin/admin-dashboard/admin-dashboard.component.1.html b/aio/content/examples/router/src/app/admin/admin-dashboard/admin-dashboard.component.1.html new file mode 100644 index 0000000000..754a262154 --- /dev/null +++ b/aio/content/examples/router/src/app/admin/admin-dashboard/admin-dashboard.component.1.html @@ -0,0 +1 @@ +Dashboard
\ No newline at end of file diff --git a/aio/content/examples/router/src/app/admin/admin-dashboard.component.2.ts b/aio/content/examples/router/src/app/admin/admin-dashboard/admin-dashboard.component.1.ts similarity index 82% rename from aio/content/examples/router/src/app/admin/admin-dashboard.component.2.ts rename to aio/content/examples/router/src/app/admin/admin-dashboard/admin-dashboard.component.1.ts index 19406bea9b..8806d7cea8 100644 --- a/aio/content/examples/router/src/app/admin/admin-dashboard.component.2.ts +++ b/aio/content/examples/router/src/app/admin/admin-dashboard/admin-dashboard.component.1.ts @@ -5,13 +5,9 @@ import { Observable } from 'rxjs'; import { map } from 'rxjs/operators'; @Component({ - template: ` -Dashboard
- -Session ID: {{ sessionId | async }}
- -Token: {{ token | async }}
- ` + selector: 'app-admin-dashboard', + templateUrl: './admin-dashboard.component.html', + styleUrls: ['./admin-dashboard.component.css'] }) export class AdminDashboardComponent implements OnInit { sessionId: ObservableDashboard
+ +Session ID: {{ sessionId | async }}
+ +Token: {{ token | async }}
\ No newline at end of file diff --git a/aio/content/examples/router/src/app/admin/admin-dashboard/admin-dashboard.component.css b/aio/content/examples/router/src/app/admin/admin-dashboard/admin-dashboard.component.css new file mode 100644 index 0000000000..e69de29bb2 diff --git a/aio/content/examples/router/src/app/admin/admin-dashboard/admin-dashboard.component.html b/aio/content/examples/router/src/app/admin/admin-dashboard/admin-dashboard.component.html new file mode 100644 index 0000000000..9c14d5b266 --- /dev/null +++ b/aio/content/examples/router/src/app/admin/admin-dashboard/admin-dashboard.component.html @@ -0,0 +1,10 @@ +Dashboard
+ +Session ID: {{ sessionId | async }}
+ +Token: {{ token | async }}
+ +Preloaded Modules +Dashboard
- -Session ID: {{ sessionId | async }}
- -Token: {{ token | async }}
- - Preloaded Modules -Manage your crises here
- ` -}) -export class ManageCrisesComponent { } diff --git a/aio/content/examples/router/src/app/admin/manage-crises/manage-crises.component.css b/aio/content/examples/router/src/app/admin/manage-crises/manage-crises.component.css new file mode 100644 index 0000000000..e69de29bb2 diff --git a/aio/content/examples/router/src/app/admin/manage-crises/manage-crises.component.html b/aio/content/examples/router/src/app/admin/manage-crises/manage-crises.component.html new file mode 100644 index 0000000000..4edfa72133 --- /dev/null +++ b/aio/content/examples/router/src/app/admin/manage-crises/manage-crises.component.html @@ -0,0 +1 @@ +Manage your crises here
\ No newline at end of file diff --git a/aio/content/examples/router/src/app/admin/manage-crises/manage-crises.component.ts b/aio/content/examples/router/src/app/admin/manage-crises/manage-crises.component.ts new file mode 100644 index 0000000000..c3fe3bb92d --- /dev/null +++ b/aio/content/examples/router/src/app/admin/manage-crises/manage-crises.component.ts @@ -0,0 +1,9 @@ +// #docregion +import { Component } from '@angular/core'; + +@Component({ + selector: 'app-manage-crises', + templateUrl: './manage-crises.component.html', + styleUrls: ['./manage-crises.component.css'] +}) +export class ManageCrisesComponent { } diff --git a/aio/content/examples/router/src/app/admin/manage-heroes.component.ts b/aio/content/examples/router/src/app/admin/manage-heroes.component.ts deleted file mode 100644 index 7f3a39893d..0000000000 --- a/aio/content/examples/router/src/app/admin/manage-heroes.component.ts +++ /dev/null @@ -1,9 +0,0 @@ -// #docregion -import { Component } from '@angular/core'; - -@Component({ - template: ` -Manage your heroes here
- ` -}) -export class ManageHeroesComponent { } diff --git a/aio/content/examples/router/src/app/admin/manage-heroes/manage-heroes.component.css b/aio/content/examples/router/src/app/admin/manage-heroes/manage-heroes.component.css new file mode 100644 index 0000000000..e69de29bb2 diff --git a/aio/content/examples/router/src/app/admin/manage-heroes/manage-heroes.component.html b/aio/content/examples/router/src/app/admin/manage-heroes/manage-heroes.component.html new file mode 100644 index 0000000000..3e5256527d --- /dev/null +++ b/aio/content/examples/router/src/app/admin/manage-heroes/manage-heroes.component.html @@ -0,0 +1 @@ +Manage your heroes here
\ No newline at end of file diff --git a/aio/content/examples/router/src/app/admin/manage-heroes/manage-heroes.component.ts b/aio/content/examples/router/src/app/admin/manage-heroes/manage-heroes.component.ts new file mode 100644 index 0000000000..cb68fb3711 --- /dev/null +++ b/aio/content/examples/router/src/app/admin/manage-heroes/manage-heroes.component.ts @@ -0,0 +1,9 @@ +// #docregion +import { Component } from '@angular/core'; + +@Component({ + selector: 'app-manage-hereos', + templateUrl: './manage-heroes.component.html', + styleUrls: ['./manage-heroes.component.css'] +}) +export class ManageHeroesComponent { } diff --git a/aio/content/examples/router/src/app/app-routing.module.1.ts b/aio/content/examples/router/src/app/app-routing.module.1.ts index 436291f499..181384575f 100644 --- a/aio/content/examples/router/src/app/app-routing.module.1.ts +++ b/aio/content/examples/router/src/app/app-routing.module.1.ts @@ -2,9 +2,9 @@ import { NgModule } from '@angular/core'; import { RouterModule, Routes } from '@angular/router'; -import { CrisisListComponent } from './crisis-list.component'; -import { HeroListComponent } from './hero-list.component'; -import { PageNotFoundComponent } from './not-found.component'; +import { CrisisListComponent } from './crisis-list/crisis-list.component'; +import { HeroListComponent } from './hero-list/hero-list.component'; +import { PageNotFoundComponent } from './page-not-found/page-not-found.component'; // #docregion appRoutes const appRoutes: Routes = [ diff --git a/aio/content/examples/router/src/app/app-routing.module.2.ts b/aio/content/examples/router/src/app/app-routing.module.2.ts index c4df89d7f8..01192901f6 100644 --- a/aio/content/examples/router/src/app/app-routing.module.2.ts +++ b/aio/content/examples/router/src/app/app-routing.module.2.ts @@ -1,14 +1,19 @@ // #docregion +// #docregion milestone3 import { NgModule } from '@angular/core'; import { RouterModule, Routes } from '@angular/router'; -import { CrisisListComponent } from './crisis-list.component'; -// import { HeroListComponent } from './hero-list.component'; // <-- delete this line -import { PageNotFoundComponent } from './not-found.component'; +import { CrisisListComponent } from './crisis-list/crisis-list.component'; +// #enddocregion milestone3 +// import { HeroListComponent } from './hero-list/hero-list.component'; // <-- delete this line +// #docregion milestone3 +import { PageNotFoundComponent } from './page-not-found/page-not-found.component'; const appRoutes: Routes = [ { path: 'crisis-center', component: CrisisListComponent }, +// #enddocregion milestone3 // { path: 'heroes', component: HeroListComponent }, // <-- delete this line +// #docregion milestone3 { path: '', redirectTo: '/heroes', pathMatch: 'full' }, { path: '**', component: PageNotFoundComponent } ]; @@ -25,3 +30,4 @@ const appRoutes: Routes = [ ] }) export class AppRoutingModule {} +// #enddocregion milestone3 diff --git a/aio/content/examples/router/src/app/app-routing.module.3.ts b/aio/content/examples/router/src/app/app-routing.module.3.ts index 354ca6e740..4351476a4e 100644 --- a/aio/content/examples/router/src/app/app-routing.module.3.ts +++ b/aio/content/examples/router/src/app/app-routing.module.3.ts @@ -3,8 +3,10 @@ import { NgModule } from '@angular/core'; import { RouterModule, Routes } from '@angular/router'; -import { ComposeMessageComponent } from './compose-message.component'; -import { PageNotFoundComponent } from './not-found.component'; +// #enddocregion v3 +import { ComposeMessageComponent } from './compose-message/compose-message.component'; +// #docregion v3 +import { PageNotFoundComponent } from './page-not-found/page-not-found.component'; const appRoutes: Routes = [ // #enddocregion v3 diff --git a/aio/content/examples/router/src/app/app-routing.module.4.ts b/aio/content/examples/router/src/app/app-routing.module.4.ts index 9c0d7bb928..5943ad7d05 100644 --- a/aio/content/examples/router/src/app/app-routing.module.4.ts +++ b/aio/content/examples/router/src/app/app-routing.module.4.ts @@ -2,9 +2,9 @@ import { NgModule } from '@angular/core'; import { RouterModule, Routes } from '@angular/router'; -import { ComposeMessageComponent } from './compose-message.component'; -import { CanDeactivateGuard } from './can-deactivate-guard.service'; -import { PageNotFoundComponent } from './not-found.component'; +import { ComposeMessageComponent } from './compose-message/compose-message.component'; +import { CanDeactivateGuard } from './can-deactivate.guard'; +import { PageNotFoundComponent } from './page-not-found/page-not-found.component'; const appRoutes: Routes = [ { @@ -25,9 +25,6 @@ const appRoutes: Routes = [ ], exports: [ RouterModule - ], - providers: [ - CanDeactivateGuard ] }) export class AppRoutingModule {} diff --git a/aio/content/examples/router/src/app/app-routing.module.5.ts b/aio/content/examples/router/src/app/app-routing.module.5.ts index a12bd2cc7e..a120771875 100644 --- a/aio/content/examples/router/src/app/app-routing.module.5.ts +++ b/aio/content/examples/router/src/app/app-routing.module.5.ts @@ -5,11 +5,10 @@ import { NgModule } from '@angular/core'; import { RouterModule, Routes } from '@angular/router'; // #enddocregion import-router -import { ComposeMessageComponent } from './compose-message.component'; -import { PageNotFoundComponent } from './not-found.component'; +import { ComposeMessageComponent } from './compose-message/compose-message.component'; +import { PageNotFoundComponent } from './page-not-found/page-not-found.component'; -import { CanDeactivateGuard } from './can-deactivate-guard.service'; -import { AuthGuard } from './auth-guard.service'; +import { AuthGuard } from './auth/auth.guard'; const appRoutes: Routes = [ @@ -21,7 +20,7 @@ const appRoutes: Routes = [ // #docregion admin, admin-1 { path: 'admin', - loadChildren: 'app/admin/admin.module#AdminModule', + loadChildren: './admin/admin.module#AdminModule', // #enddocregion admin-1 canLoad: [AuthGuard] // #docregion admin-1 @@ -40,9 +39,6 @@ const appRoutes: Routes = [ ], exports: [ RouterModule - ], - providers: [ - CanDeactivateGuard ] }) export class AppRoutingModule {} diff --git a/aio/content/examples/router/src/app/app-routing.module.6.ts b/aio/content/examples/router/src/app/app-routing.module.6.ts index 83a6ab3521..e1c81f2498 100644 --- a/aio/content/examples/router/src/app/app-routing.module.6.ts +++ b/aio/content/examples/router/src/app/app-routing.module.6.ts @@ -8,11 +8,10 @@ import { // #docregion preload-v1 } from '@angular/router'; -import { ComposeMessageComponent } from './compose-message.component'; -import { PageNotFoundComponent } from './not-found.component'; +import { ComposeMessageComponent } from './compose-message/compose-message.component'; +import { PageNotFoundComponent } from './page-not-found/page-not-found.component'; -import { CanDeactivateGuard } from './can-deactivate-guard.service'; -import { AuthGuard } from './auth-guard.service'; +import { AuthGuard } from './auth/auth.guard'; const appRoutes: Routes = [ { @@ -22,12 +21,12 @@ const appRoutes: Routes = [ }, { path: 'admin', - loadChildren: 'app/admin/admin.module#AdminModule', + loadChildren: './admin/admin.module#AdminModule', canLoad: [AuthGuard] }, { path: 'crisis-center', - loadChildren: 'app/crisis-center/crisis-center.module#CrisisCenterModule' + loadChildren: './crisis-center/crisis-center.module#CrisisCenterModule' }, { path: '', redirectTo: '/heroes', pathMatch: 'full' }, { path: '**', component: PageNotFoundComponent } @@ -49,9 +48,6 @@ const appRoutes: Routes = [ ], exports: [ RouterModule - ], - providers: [ - CanDeactivateGuard ] }) export class AppRoutingModule {} diff --git a/aio/content/examples/router/src/app/app-routing.module.ts b/aio/content/examples/router/src/app/app-routing.module.ts index be5dd1d5c9..ffad588287 100644 --- a/aio/content/examples/router/src/app/app-routing.module.ts +++ b/aio/content/examples/router/src/app/app-routing.module.ts @@ -3,12 +3,11 @@ import { NgModule } from '@angular/core'; import { RouterModule, Routes } from '@angular/router'; -import { ComposeMessageComponent } from './compose-message.component'; -import { PageNotFoundComponent } from './not-found.component'; +import { ComposeMessageComponent } from './compose-message/compose-message.component'; +import { PageNotFoundComponent } from './page-not-found/page-not-found.component'; -import { CanDeactivateGuard } from './can-deactivate-guard.service'; -import { AuthGuard } from './auth-guard.service'; -import { SelectivePreloadingStrategy } from './selective-preloading-strategy'; +import { AuthGuard } from './auth/auth.guard'; +import { SelectivePreloadingStrategyService } from './selective-preloading-strategy.service'; const appRoutes: Routes = [ { @@ -18,13 +17,13 @@ const appRoutes: Routes = [ }, { path: 'admin', - loadChildren: 'app/admin/admin.module#AdminModule', + loadChildren: './admin/admin.module#AdminModule', canLoad: [AuthGuard] }, // #docregion preload-v2 { path: 'crisis-center', - loadChildren: 'app/crisis-center/crisis-center.module#CrisisCenterModule', + loadChildren: './crisis-center/crisis-center.module#CrisisCenterModule', data: { preload: true } }, // #enddocregion preload-v2 @@ -37,18 +36,13 @@ const appRoutes: Routes = [ RouterModule.forRoot( appRoutes, { - enableTracing: true, // <-- debugging purposes only - preloadingStrategy: SelectivePreloadingStrategy, - + enableTracing: false, // <-- debugging purposes only + preloadingStrategy: SelectivePreloadingStrategyService, } ) ], exports: [ RouterModule - ], - providers: [ - CanDeactivateGuard, - SelectivePreloadingStrategy ] }) export class AppRoutingModule { } diff --git a/aio/content/examples/router/src/app/app.component.1.html b/aio/content/examples/router/src/app/app.component.1.html new file mode 100644 index 0000000000..255232483e --- /dev/null +++ b/aio/content/examples/router/src/app/app.component.1.html @@ -0,0 +1,7 @@ + +{{message}}
-- - -
` + selector: 'app-login', + templateUrl: './login.component.html', + styleUrls: ['./login.component.css'] }) export class LoginComponent { message: string; diff --git a/aio/content/examples/router/src/app/auth/login/login.component.css b/aio/content/examples/router/src/app/auth/login/login.component.css new file mode 100644 index 0000000000..e69de29bb2 diff --git a/aio/content/examples/router/src/app/auth/login/login.component.html b/aio/content/examples/router/src/app/auth/login/login.component.html new file mode 100644 index 0000000000..adac1fb788 --- /dev/null +++ b/aio/content/examples/router/src/app/auth/login/login.component.html @@ -0,0 +1,6 @@ +{{message}}
++ + +
\ No newline at end of file diff --git a/aio/content/examples/router/src/app/login.component.ts b/aio/content/examples/router/src/app/auth/login/login.component.ts similarity index 81% rename from aio/content/examples/router/src/app/login.component.ts rename to aio/content/examples/router/src/app/auth/login/login.component.ts index 1a6fae162f..5ebfd58b21 100644 --- a/aio/content/examples/router/src/app/login.component.ts +++ b/aio/content/examples/router/src/app/auth/login/login.component.ts @@ -2,16 +2,12 @@ import { Component } from '@angular/core'; import { Router, NavigationExtras } from '@angular/router'; -import { AuthService } from './auth.service'; +import { AuthService } from '../auth.service'; @Component({ - template: ` -{{message}}
-- - -
` + selector: 'app-login', + templateUrl: './login.component.html', + styleUrls: ['./login.component.css'] }) export class LoginComponent { message: string; diff --git a/aio/content/examples/router/src/app/can-deactivate-guard.service.1.ts b/aio/content/examples/router/src/app/can-deactivate.guard.1.ts similarity index 93% rename from aio/content/examples/router/src/app/can-deactivate-guard.service.1.ts rename to aio/content/examples/router/src/app/can-deactivate.guard.1.ts index 35af6226fb..45ccd1726d 100644 --- a/aio/content/examples/router/src/app/can-deactivate-guard.service.1.ts +++ b/aio/content/examples/router/src/app/can-deactivate.guard.1.ts @@ -5,9 +5,11 @@ import { CanDeactivate, ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router'; -import { CrisisDetailComponent } from './crisis-center/crisis-detail.component'; +import { CrisisDetailComponent } from './crisis-center/crisis-detail/crisis-detail.component'; -@Injectable() +@Injectable({ + providedIn: 'root' +}) export class CanDeactivateGuard implements CanDeactivateWelcome to the Crisis Center
- ` -}) -export class CrisisCenterHomeComponent { } diff --git a/aio/content/examples/router/src/app/crisis-center/crisis-center-home/crisis-center-home.component.css b/aio/content/examples/router/src/app/crisis-center/crisis-center-home/crisis-center-home.component.css new file mode 100644 index 0000000000..e69de29bb2 diff --git a/aio/content/examples/router/src/app/crisis-center/crisis-center-home/crisis-center-home.component.html b/aio/content/examples/router/src/app/crisis-center/crisis-center-home/crisis-center-home.component.html new file mode 100644 index 0000000000..f3c7d4e50c --- /dev/null +++ b/aio/content/examples/router/src/app/crisis-center/crisis-center-home/crisis-center-home.component.html @@ -0,0 +1 @@ +Welcome to the Crisis Center
\ No newline at end of file diff --git a/aio/content/examples/router/src/app/crisis-center/crisis-center-home/crisis-center-home.component.ts b/aio/content/examples/router/src/app/crisis-center/crisis-center-home/crisis-center-home.component.ts new file mode 100644 index 0000000000..c2b7cde814 --- /dev/null +++ b/aio/content/examples/router/src/app/crisis-center/crisis-center-home/crisis-center-home.component.ts @@ -0,0 +1,9 @@ +// #docregion +import { Component } from '@angular/core'; + +@Component({ + selector: 'app-crisis-center-home', + templateUrl: './crisis-center-home.component.html', + styleUrls: ['./crisis-center-home.component.css'] +}) +export class CrisisCenterHomeComponent { } diff --git a/aio/content/examples/router/src/app/crisis-center/crisis-center-routing.module.1.ts b/aio/content/examples/router/src/app/crisis-center/crisis-center-routing.module.1.ts index 8ef60e68a1..c002b2ebb3 100644 --- a/aio/content/examples/router/src/app/crisis-center/crisis-center-routing.module.1.ts +++ b/aio/content/examples/router/src/app/crisis-center/crisis-center-routing.module.1.ts @@ -3,10 +3,10 @@ import { NgModule } from '@angular/core'; import { RouterModule, Routes } from '@angular/router'; -import { CrisisCenterHomeComponent } from './crisis-center-home.component'; -import { CrisisListComponent } from './crisis-list.component'; -import { CrisisCenterComponent } from './crisis-center.component'; -import { CrisisDetailComponent } from './crisis-detail.component'; +import { CrisisCenterHomeComponent } from './crisis-center-home/crisis-center-home.component'; +import { CrisisListComponent } from './crisis-list/crisis-list.component'; +import { CrisisCenterComponent } from './crisis-center/crisis-center.component'; +import { CrisisDetailComponent } from './crisis-detail/crisis-detail.component'; // #docregion routes const crisisCenterRoutes: Routes = [ diff --git a/aio/content/examples/router/src/app/crisis-center/crisis-center-routing.module.2.ts b/aio/content/examples/router/src/app/crisis-center/crisis-center-routing.module.2.ts index 9e9b514968..5bc0dfee02 100644 --- a/aio/content/examples/router/src/app/crisis-center/crisis-center-routing.module.2.ts +++ b/aio/content/examples/router/src/app/crisis-center/crisis-center-routing.module.2.ts @@ -3,30 +3,23 @@ import { NgModule } from '@angular/core'; import { RouterModule, Routes } from '@angular/router'; -import { CrisisCenterHomeComponent } from './crisis-center-home.component'; -import { CrisisListComponent } from './crisis-list.component'; -import { CrisisCenterComponent } from './crisis-center.component'; -import { CrisisDetailComponent } from './crisis-detail.component'; +import { CrisisCenterHomeComponent } from './crisis-center-home/crisis-center-home.component'; +import { CrisisListComponent } from './crisis-list/crisis-list.component'; +import { CrisisCenterComponent } from './crisis-center/crisis-center.component'; +import { CrisisDetailComponent } from './crisis-detail/crisis-detail.component'; // #enddocregion routes // #docregion can-deactivate-guard -import { CanDeactivateGuard } from '../can-deactivate-guard.service'; +import { CanDeactivateGuard } from '../can-deactivate.guard'; // #enddocregion can-deactivate-guard // #docregion crisis-detail-resolver -import { CrisisDetailResolver } from './crisis-detail-resolver.service'; +import { CrisisDetailResolverService } from './crisis-detail-resolver.service'; // #enddocregion crisis-detail-resolver // #docregion routes const crisisCenterRoutes: Routes = [ // #enddocregion routes - // #docregion redirect, routes - { - path: '', - redirectTo: '/crisis-center', - pathMatch: 'full' - }, - // #enddocregion redirect, routes // #docregion routes { path: 'crisis-center', @@ -45,7 +38,7 @@ const crisisCenterRoutes: Routes = [ // #enddocregion can-deactivate-guard // #docregion crisis-detail-resolver resolve: { - crisis: CrisisDetailResolver + crisis: CrisisDetailResolverService } // #enddocregion crisis-detail-resolver // #docregion routes diff --git a/aio/content/examples/router/src/app/crisis-center/crisis-center-routing.module.3.ts b/aio/content/examples/router/src/app/crisis-center/crisis-center-routing.module.3.ts index 6d605dbe84..f134bd34e9 100644 --- a/aio/content/examples/router/src/app/crisis-center/crisis-center-routing.module.3.ts +++ b/aio/content/examples/router/src/app/crisis-center/crisis-center-routing.module.3.ts @@ -3,20 +3,15 @@ import { NgModule } from '@angular/core'; import { RouterModule, Routes } from '@angular/router'; -import { CrisisCenterHomeComponent } from './crisis-center-home.component'; -import { CrisisListComponent } from './crisis-list.component'; -import { CrisisCenterComponent } from './crisis-center.component'; -import { CrisisDetailComponent } from './crisis-detail.component'; +import { CrisisCenterHomeComponent } from './crisis-center-home/crisis-center-home.component'; +import { CrisisListComponent } from './crisis-list/crisis-list.component'; +import { CrisisCenterComponent } from './crisis-center/crisis-center.component'; +import { CrisisDetailComponent } from './crisis-detail/crisis-detail.component'; // #docregion can-deactivate-guard -import { CanDeactivateGuard } from '../can-deactivate-guard.service'; +import { CanDeactivateGuard } from '../can-deactivate.guard'; const crisisCenterRoutes: Routes = [ - { - path: '', - redirectTo: '/crisis-center', - pathMatch: 'full' - }, { path: 'crisis-center', component: CrisisCenterComponent, diff --git a/aio/content/examples/router/src/app/crisis-center/crisis-center-routing.module.4.ts b/aio/content/examples/router/src/app/crisis-center/crisis-center-routing.module.4.ts index b7ac88e852..03ffed2ec2 100644 --- a/aio/content/examples/router/src/app/crisis-center/crisis-center-routing.module.4.ts +++ b/aio/content/examples/router/src/app/crisis-center/crisis-center-routing.module.4.ts @@ -3,25 +3,15 @@ import { NgModule } from '@angular/core'; import { RouterModule, Routes } from '@angular/router'; -import { CrisisCenterHomeComponent } from './crisis-center-home.component'; -import { CrisisListComponent } from './crisis-list.component'; -import { CrisisCenterComponent } from './crisis-center.component'; -import { CrisisDetailComponent } from './crisis-detail.component'; +import { CrisisCenterHomeComponent } from './crisis-center-home/crisis-center-home.component'; +import { CrisisListComponent } from './crisis-list/crisis-list.component'; +import { CrisisCenterComponent } from './crisis-center/crisis-center.component'; +import { CrisisDetailComponent } from './crisis-detail/crisis-detail.component'; -import { CanDeactivateGuard } from '../can-deactivate-guard.service'; +import { CanDeactivateGuard } from '../can-deactivate.guard'; +import { CrisisDetailResolverService } from './crisis-detail-resolver.service'; -// #docregion crisis-detail-resolver -import { CrisisDetailResolver } from './crisis-detail-resolver.service'; - -// #enddocregion crisis-detail-resolver const crisisCenterRoutes: Routes = [ - // #docregion redirect - { - path: '', - redirectTo: '/crisis-center', - pathMatch: 'full' - }, - // #enddocregion redirect { path: 'crisis-center', component: CrisisCenterComponent, @@ -35,7 +25,7 @@ const crisisCenterRoutes: Routes = [ component: CrisisDetailComponent, canDeactivate: [CanDeactivateGuard], resolve: { - crisis: CrisisDetailResolver + crisis: CrisisDetailResolverService } }, { @@ -48,18 +38,13 @@ const crisisCenterRoutes: Routes = [ } ]; -// #docregion crisis-detail-resolver @NgModule({ imports: [ RouterModule.forChild(crisisCenterRoutes) ], exports: [ RouterModule - ], - providers: [ - CrisisDetailResolver ] }) export class CrisisCenterRoutingModule { } -// #enddocregion crisis-detail-resolver // #enddocregion diff --git a/aio/content/examples/router/src/app/crisis-center/crisis-center-routing.module.ts b/aio/content/examples/router/src/app/crisis-center/crisis-center-routing.module.ts index c01d592455..393deb7d8d 100644 --- a/aio/content/examples/router/src/app/crisis-center/crisis-center-routing.module.ts +++ b/aio/content/examples/router/src/app/crisis-center/crisis-center-routing.module.ts @@ -3,13 +3,13 @@ import { NgModule } from '@angular/core'; import { RouterModule, Routes } from '@angular/router'; -import { CrisisCenterHomeComponent } from './crisis-center-home.component'; -import { CrisisListComponent } from './crisis-list.component'; -import { CrisisCenterComponent } from './crisis-center.component'; -import { CrisisDetailComponent } from './crisis-detail.component'; +import { CrisisCenterHomeComponent } from './crisis-center-home/crisis-center-home.component'; +import { CrisisListComponent } from './crisis-list/crisis-list.component'; +import { CrisisCenterComponent } from './crisis-center/crisis-center.component'; +import { CrisisDetailComponent } from './crisis-detail/crisis-detail.component'; -import { CanDeactivateGuard } from '../can-deactivate-guard.service'; -import { CrisisDetailResolver } from './crisis-detail-resolver.service'; +import { CanDeactivateGuard } from '../can-deactivate.guard'; +import { CrisisDetailResolverService } from './crisis-detail-resolver.service'; const crisisCenterRoutes: Routes = [ { @@ -25,7 +25,7 @@ const crisisCenterRoutes: Routes = [ component: CrisisDetailComponent, canDeactivate: [CanDeactivateGuard], resolve: { - crisis: CrisisDetailResolver + crisis: CrisisDetailResolverService } }, { @@ -44,9 +44,6 @@ const crisisCenterRoutes: Routes = [ ], exports: [ RouterModule - ], - providers: [ - CrisisDetailResolver ] }) export class CrisisCenterRoutingModule { } diff --git a/aio/content/examples/router/src/app/crisis-center/crisis-center.component.ts b/aio/content/examples/router/src/app/crisis-center/crisis-center.component.ts deleted file mode 100644 index c7d7fe412d..0000000000 --- a/aio/content/examples/router/src/app/crisis-center/crisis-center.component.ts +++ /dev/null @@ -1,10 +0,0 @@ -// #docregion -import { Component } from '@angular/core'; - -@Component({ - template: ` -- - -
-+ + +
+- - -
-Get your crisis here
diff --git a/aio/content/examples/router/src/app/crisis-list.component.ts b/aio/content/examples/router/src/app/crisis-list/crisis-list.component.ts similarity index 52% rename from aio/content/examples/router/src/app/crisis-list.component.ts rename to aio/content/examples/router/src/app/crisis-list/crisis-list.component.ts index 6caa3653b5..2fa2e05e49 100644 --- a/aio/content/examples/router/src/app/crisis-list.component.ts +++ b/aio/content/examples/router/src/app/crisis-list/crisis-list.component.ts @@ -3,8 +3,8 @@ import { Component } from '@angular/core'; @Component({ - template: ` -Get your crisis here
` + selector: 'app-crisis-list', + templateUrl: './crisis-list.component.html', + styleUrls: ['./crisis-list.component.css'] }) export class CrisisListComponent { } diff --git a/aio/content/examples/router/src/app/dialog.service.ts b/aio/content/examples/router/src/app/dialog.service.ts index d9f7f1e163..218822bc0e 100644 --- a/aio/content/examples/router/src/app/dialog.service.ts +++ b/aio/content/examples/router/src/app/dialog.service.ts @@ -7,7 +7,9 @@ import { Observable, of } from 'rxjs'; * DialogService makes this app easier to test by faking this service. * TODO: better modal implementation that doesn't use window.confirm */ -@Injectable() +@Injectable({ + providedIn: 'root' +}) export class DialogService { /** * Ask user to confirm an action. `message` explains the action and choices. diff --git a/aio/content/examples/router/src/app/hero-list.component.ts b/aio/content/examples/router/src/app/hero-list.component.ts deleted file mode 100644 index 7a8f97ca1e..0000000000 --- a/aio/content/examples/router/src/app/hero-list.component.ts +++ /dev/null @@ -1,13 +0,0 @@ -/// Initial empty version -// #docregion -import { Component } from '@angular/core'; - -@Component({ - template: ` -Get your heroes here
- - - ` -}) -export class HeroListComponent { } diff --git a/aio/content/examples/router/src/app/hero-list/hero-list.component.css b/aio/content/examples/router/src/app/hero-list/hero-list.component.css new file mode 100644 index 0000000000..e69de29bb2 diff --git a/aio/content/examples/router/src/app/hero-list/hero-list.component.html b/aio/content/examples/router/src/app/hero-list/hero-list.component.html new file mode 100644 index 0000000000..58747e208a --- /dev/null +++ b/aio/content/examples/router/src/app/hero-list/hero-list.component.html @@ -0,0 +1,6 @@ + +Get your heroes here
+ + + diff --git a/aio/content/examples/router/src/app/hero-list/hero-list.component.ts b/aio/content/examples/router/src/app/hero-list/hero-list.component.ts new file mode 100644 index 0000000000..5ee06903c0 --- /dev/null +++ b/aio/content/examples/router/src/app/hero-list/hero-list.component.ts @@ -0,0 +1,10 @@ + +// #docregion +import { Component } from '@angular/core'; + +@Component({ + selector: 'app-hero-list', + templateUrl: './hero-list.component.html', + styleUrls: ['./hero-list.component.css'] +}) +export class HeroListComponent { } diff --git a/aio/content/examples/router/src/app/heroes/hero-detail.component.1.ts b/aio/content/examples/router/src/app/heroes/hero-detail/hero-detail.component.1.ts similarity index 70% rename from aio/content/examples/router/src/app/heroes/hero-detail.component.1.ts rename to aio/content/examples/router/src/app/heroes/hero-detail/hero-detail.component.1.ts index 511b12d8a7..42cb60e1f8 100644 --- a/aio/content/examples/router/src/app/heroes/hero-detail.component.1.ts +++ b/aio/content/examples/router/src/app/heroes/hero-detail/hero-detail.component.1.ts @@ -9,24 +9,13 @@ import { Observable } from 'rxjs'; import { Router, ActivatedRoute, ParamMap } from '@angular/router'; // #enddocregion imports -import { Hero, HeroService } from './hero.service'; +import { HeroService } from '../hero.service'; +import { Hero } from '../hero'; @Component({ - template: ` -- -
-- -
-- -
-+ +
+RoutesRecognized
- RouteConfigLoadStart
@@ -407,6 +412,85 @@ During each navigation, the `Router` emits navigation events through the `Router
RoutesRecognized
+ GuardsCheckStart
+ ChildActivationStart
+ GuardsCheckEnd
+ ResolveStart
+ ResolveEnd
+ ChildActivationEnd
+ NavigationEnd
@@ -440,9 +524,20 @@ During each navigation, the `Router` emits navigation events through the `Router
Scroll
+