docs(router): chalin router copyedits #3054 (#3060)

* docs(router): chalin copyedits
* docs(router): bell copy edits + routing module order & inspect config
This commit is contained in:
Ward Bell 2017-01-01 00:25:52 -08:00 committed by GitHub
parent 7c9ff12a76
commit ce174a26fb
12 changed files with 432 additions and 349 deletions

View File

@ -1,14 +1,14 @@
// #docplaster
// #docregion // #docregion
// #docregion v2
import { NgModule } from '@angular/core'; import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router'; import { RouterModule, Routes } from '@angular/router';
import { CrisisListComponent } from './crisis-list.component'; import { CrisisListComponent } from './crisis-list.component';
// import { HeroListComponent } from './hero-list.component'; // <-- delete this line
import { PageNotFoundComponent } from './not-found.component'; import { PageNotFoundComponent } from './not-found.component';
const appRoutes: Routes = [ const appRoutes: Routes = [
{ path: 'crisis-center', component: CrisisListComponent }, { path: 'crisis-center', component: CrisisListComponent },
// { path: 'heroes', component: HeroListComponent }, // <-- delete this line
{ path: '', redirectTo: '/heroes', pathMatch: 'full' }, { path: '', redirectTo: '/heroes', pathMatch: 'full' },
{ path: '**', component: PageNotFoundComponent } { path: '**', component: PageNotFoundComponent }
]; ];

View File

@ -8,7 +8,7 @@ import { PageNotFoundComponent } from './not-found.component';
import { CanDeactivateGuard } from './can-deactivate-guard.service'; import { CanDeactivateGuard } from './can-deactivate-guard.service';
import { AuthGuard } from './auth-guard.service'; import { AuthGuard } from './auth-guard.service';
import { SelectivePreloadingStrategy } from './selective-preloading-strategy'; import { SelectivePreloadingStrategy } from './selective-preloading-strategy';
const appRoutes: Routes = [ const appRoutes: Routes = [
{ {
@ -47,4 +47,4 @@ const appRoutes: Routes = [
SelectivePreloadingStrategy SelectivePreloadingStrategy
] ]
}) })
export class AppRoutingModule {} export class AppRoutingModule { }

View File

@ -9,9 +9,9 @@ import { Component } from '@angular/core';
<nav> <nav>
<a routerLink="/crisis-center" routerLinkActive="active">Crisis Center</a> <a routerLink="/crisis-center" routerLinkActive="active">Crisis Center</a>
<a routerLink="/heroes" routerLinkActive="active">Heroes</a> <a routerLink="/heroes" routerLinkActive="active">Heroes</a>
// #docregion contact-link // #docregion contact-link
<a [routerLink]="[{ outlets: { popup: ['compose'] } }]">Contact</a> <a [routerLink]="[{ outlets: { popup: ['compose'] } }]">Contact</a>
// #enddocregion contact-link // #enddocregion contact-link
</nav> </nav>
// #docregion outlets // #docregion outlets
<router-outlet></router-outlet> <router-outlet></router-outlet>

View File

@ -11,12 +11,14 @@ import { CrisisListComponent } from './crisis-list.component';
import { PageNotFoundComponent } from './not-found.component'; import { PageNotFoundComponent } from './not-found.component';
@NgModule({ @NgModule({
// #docregion module-imports
imports: [ imports: [
BrowserModule, BrowserModule,
FormsModule, FormsModule,
HeroesModule, HeroesModule,
AppRoutingModule AppRoutingModule
], ],
// #enddocregion module-imports
declarations: [ declarations: [
AppComponent, AppComponent,
CrisisListComponent, CrisisListComponent,

View File

@ -1,8 +1,12 @@
// #docplaster
// #docregion // #docregion
import { NgModule } from '@angular/core'; import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser'; import { BrowserModule } from '@angular/platform-browser';
import { FormsModule } from '@angular/forms'; import { FormsModule } from '@angular/forms';
// #docregion inspect-config
import { Router } from '@angular/router';
// #enddocregion inspect-config
import { AppComponent } from './app.component'; import { AppComponent } from './app.component';
import { AppRoutingModule } from './app-routing.module'; import { AppRoutingModule } from './app-routing.module';
@ -33,4 +37,11 @@ import { DialogService } from './dialog.service';
], ],
bootstrap: [ AppComponent ] bootstrap: [ AppComponent ]
}) })
export class AppModule { } // #docregion inspect-config
export class AppModule {
// Diagnostic only: inspect router configuration
constructor(router: Router) {
console.log('Routes: ', JSON.stringify(router.config, undefined, 2));
}
}
// #enddocregion inspect-config

View File

@ -1,5 +1,5 @@
// #docplaster // #docplaster
// #docregion // #docregion , mock-crises
export class Crisis { export class Crisis {
constructor(public id: number, public name: string) { } constructor(public id: number, public name: string) { }
} }
@ -10,6 +10,7 @@ const CRISES = [
new Crisis(3, 'Giant Asteroid Heading For Earth'), new Crisis(3, 'Giant Asteroid Heading For Earth'),
new Crisis(4, 'Procrastinators Meeting Delayed Again'), new Crisis(4, 'Procrastinators Meeting Delayed Again'),
]; ];
// #enddocregion mock-crises
let crisesPromise = Promise.resolve(CRISES); let crisesPromise = Promise.resolve(CRISES);
@ -28,8 +29,7 @@ export class CrisisService {
.then(crises => crises.find(crisis => crisis.id === +id)); .then(crises => crises.find(crisis => crisis.id === +id));
} }
// #enddocregion // #enddocregion
addCrisis(name: string) { addCrisis(name: string) {
name = name.trim(); name = name.trim();
if (name) { if (name) {
@ -37,6 +37,5 @@ export class CrisisService {
crisesPromise.then(crises => crises.push(crisis)); crisesPromise.then(crises => crises.push(crisis));
} }
} }
// #docregion // #docregion
} }
// #enddocregion

View File

@ -1,25 +0,0 @@
// #docregion
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { HeroListComponent } from './hero-list.component';
import { HeroDetailComponent } from './hero-detail.component';
import { HeroService } from './hero.service';
@NgModule({
imports: [
CommonModule,
FormsModule
],
declarations: [
HeroListComponent,
HeroDetailComponent
],
providers: [
HeroService
]
})
export class HeroesModule {}
// #enddocregion

View File

@ -1,4 +1,6 @@
// #docplaster
// #docregion // #docregion
// #docregion v1
import { NgModule } from '@angular/core'; import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common'; import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms'; import { FormsModule } from '@angular/forms';
@ -8,23 +10,24 @@ import { HeroDetailComponent } from './hero-detail.component';
import { HeroService } from './hero.service'; import { HeroService } from './hero.service';
// #docregion heroes-routes // #enddocregion v1
import { HeroRoutingModule } from './heroes-routing.module'; import { HeroRoutingModule } from './heroes-routing.module';
// #docregion v1
@NgModule({ @NgModule({
imports: [ imports: [
CommonModule, CommonModule,
FormsModule, FormsModule,
// #enddocregion v1
HeroRoutingModule HeroRoutingModule
// #docregion v1
], ],
declarations: [ declarations: [
HeroListComponent, HeroListComponent,
HeroDetailComponent HeroDetailComponent
], ],
providers: [ providers: [ HeroService ]
HeroService
]
}) })
// #enddocregion heroes-routes
export class HeroesModule {} export class HeroesModule {}
// #enddocregion v1
// #enddocregion // #enddocregion

View File

@ -6,7 +6,7 @@
<!-- #docregion base-href --> <!-- #docregion base-href -->
<base href="/"> <base href="/">
<!-- #enddocregion base-href --> <!-- #enddocregion base-href -->
<title>Router Sample</title> <title>Angular Router</title>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="styles.css"> <link rel="stylesheet" href="styles.css">

View File

@ -3,7 +3,7 @@
"files":[ "files":[
"!**/*.d.ts", "!**/*.d.ts",
"!**/*.js", "!**/*.js",
"!**/*.[1].*" "!**/*.[1,2].*"
], ],
"tags": ["tutorial", "tour", "heroes"] "tags": ["tutorial", "tour", "heroes"]
} }

File diff suppressed because it is too large Load Diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 4.6 KiB