From 0fc40284dd07076c18df2d704300ace3b58ca0d8 Mon Sep 17 00:00:00 2001 From: Ward Bell Date: Tue, 21 Mar 2017 11:08:09 -0700 Subject: [PATCH] [WIP] docs(toh): copyedits to conform to Google doc standards (#3032) (#3077) --- .../ts-snippets/app.component.snippets.pt1.ts | 39 -- .../_examples/toh-1/ts/app/app.component.1.ts | 44 ++ public/docs/_examples/toh-1/ts/plnkr.json | 3 +- .../toh-1/ts/src/app/app.component.ts | 5 +- .../_examples/toh-1/ts/src/app/app.module.ts | 4 +- public/docs/_examples/toh-2/e2e-spec.ts | 2 +- .../app/app.component.1.html} | 42 +- public/docs/_examples/toh-2/ts/plnkr.json | 3 +- public/docs/_examples/toh-3/e2e-spec.ts | 2 +- .../toh-3/ts/app/app.component.1.html | 12 + .../toh-3/ts/app/hero-detail.component.1.ts | 35 + public/docs/_examples/toh-3/ts/plnkr.json | 3 +- .../toh-3/ts/src/app/app.component.ts | 2 +- .../_examples/toh-3/ts/src/app/app.module.ts | 6 +- .../toh-3/ts/src/app/hero-detail.component.ts | 28 +- public/docs/_examples/toh-4/e2e-spec.ts | 2 +- .../toh-4/ts/src/app/app.component.1.ts | 2 +- .../toh-4/ts/src/app/app.component.ts | 2 +- .../toh-4/ts/src/app/hero-detail.component.ts | 2 +- public/docs/_examples/toh-5/e2e-spec.ts | 2 +- .../toh-5/ts/src/app/hero-detail.component.ts | 2 +- public/docs/_examples/toh-6/e2e-spec.ts | 2 +- .../toh-6/ts/src/app/hero-detail.component.ts | 2 +- public/docs/ts/latest/guide/router.jade | 2 +- public/docs/ts/latest/guide/style-guide.jade | 2 + public/docs/ts/latest/tutorial/_data.json | 12 +- public/docs/ts/latest/tutorial/index.jade | 74 +- public/docs/ts/latest/tutorial/toh-pt1.jade | 196 +++--- public/docs/ts/latest/tutorial/toh-pt2.jade | 323 ++++----- public/docs/ts/latest/tutorial/toh-pt3.jade | 328 ++++----- public/docs/ts/latest/tutorial/toh-pt4.jade | 411 ++++++----- public/docs/ts/latest/tutorial/toh-pt5.jade | 657 +++++++++--------- public/docs/ts/latest/tutorial/toh-pt6.jade | 439 ++++++------ 33 files changed, 1326 insertions(+), 1364 deletions(-) delete mode 100644 public/docs/_examples/toh-1/ts-snippets/app.component.snippets.pt1.ts create mode 100644 public/docs/_examples/toh-1/ts/app/app.component.1.ts rename public/docs/_examples/toh-2/{ts-snippets/app.component.snippets.pt2.ts => ts/app/app.component.1.html} (59%) create mode 100644 public/docs/_examples/toh-3/ts/app/app.component.1.html create mode 100644 public/docs/_examples/toh-3/ts/app/hero-detail.component.1.ts diff --git a/public/docs/_examples/toh-1/ts-snippets/app.component.snippets.pt1.ts b/public/docs/_examples/toh-1/ts-snippets/app.component.snippets.pt1.ts deleted file mode 100644 index 05180b0c83..0000000000 --- a/public/docs/_examples/toh-1/ts-snippets/app.component.snippets.pt1.ts +++ /dev/null @@ -1,39 +0,0 @@ -// #docregion show-hero -template: '

{{title}}

{{hero}} details!

' -// #enddocregion show-hero - -// #docregion show-hero-2 -template: '

{{title}}

{{hero.name}} details!

' -// #enddocregion show-hero-2 - -// #docregion show-hero-properties -template: '

{{title}}

{{hero.name}} details!

{{hero.id}}
{{hero.name}}
' -// #enddocregion show-hero-properties - -// #docregion multi-line-strings -template:` -

{{title}}

-

{{hero.name}} details!

-
{{hero.id}}
-
{{hero.name}}
- ` -// #enddocregion multi-line-strings - -// #docregion editing-Hero -template:` -

{{title}}

-

{{hero.name}} details!

-
{{hero.id}}
-
- - -
- ` -// #enddocregion editing-Hero - -// #docregion app-component-1 -export class AppComponent { - title = 'Tour of Heroes'; - hero = 'Windstorm'; -} -// #enddocregion app-component-1 diff --git a/public/docs/_examples/toh-1/ts/app/app.component.1.ts b/public/docs/_examples/toh-1/ts/app/app.component.1.ts new file mode 100644 index 0000000000..371fe39f90 --- /dev/null +++ b/public/docs/_examples/toh-1/ts/app/app.component.1.ts @@ -0,0 +1,44 @@ +import { Component } from '@angular/core'; + +let t = { +// #docregion show-hero +template: `

{{title}}

{{hero}} details!

` +// #enddocregion show-hero +}; + +t = { +// #docregion show-hero-2 +template: `

{{title}}

{{hero.name}} details!

` +// #enddocregion show-hero-2 +}; + +t = { +// #docregion multi-line-strings +template: ` +

{{title}}

+

{{hero.name}} details!

+
{{hero.id}}
+
{{hero.name}}
+ ` +// #enddocregion multi-line-strings +}; + + +/* +// #docregion name-input +
+ + +
+// #enddocregion name-input +*/ + +///////////////// + +@Component(t) +// #docregion app-component-1 +export class AppComponent { + title = 'Tour of Heroes'; + hero = 'Windstorm'; +} +// #enddocregion app-component-1 diff --git a/public/docs/_examples/toh-1/ts/plnkr.json b/public/docs/_examples/toh-1/ts/plnkr.json index b5d016f282..ca75131d96 100644 --- a/public/docs/_examples/toh-1/ts/plnkr.json +++ b/public/docs/_examples/toh-1/ts/plnkr.json @@ -3,7 +3,8 @@ "basePath": "src/", "files":[ "!**/*.d.ts", - "!**/*.js" + "!**/*.js", + "!**/*.[1].*" ], "tags": ["tutorial", "tour", "heroes"] } diff --git a/public/docs/_examples/toh-1/ts/src/app/app.component.ts b/public/docs/_examples/toh-1/ts/src/app/app.component.ts index b61fac3c0b..602781b9ba 100644 --- a/public/docs/_examples/toh-1/ts/src/app/app.component.ts +++ b/public/docs/_examples/toh-1/ts/src/app/app.component.ts @@ -1,4 +1,4 @@ -// #docregion pt1 +// #docregion import { Component } from '@angular/core'; // #docregion hero-class-1 @@ -10,6 +10,7 @@ export class Hero { @Component({ selector: 'my-app', + // #docregion editing-Hero template: `

{{title}}

{{hero.name}} details!

@@ -19,6 +20,7 @@ export class Hero { ` + // #enddocregion editing-Hero }) export class AppComponent { title = 'Tour of Heroes'; @@ -29,4 +31,3 @@ export class AppComponent { }; // #enddocregion hero-property-1 } -// #enddocregion pt1 diff --git a/public/docs/_examples/toh-1/ts/src/app/app.module.ts b/public/docs/_examples/toh-1/ts/src/app/app.module.ts index 4c0b77ea48..8e87678efc 100644 --- a/public/docs/_examples/toh-1/ts/src/app/app.module.ts +++ b/public/docs/_examples/toh-1/ts/src/app/app.module.ts @@ -1,14 +1,14 @@ // #docregion import { NgModule } from '@angular/core'; import { BrowserModule } from '@angular/platform-browser'; -import { FormsModule } from '@angular/forms'; +import { FormsModule } from '@angular/forms'; // <-- NgModel lives here import { AppComponent } from './app.component'; @NgModule({ imports: [ BrowserModule, - FormsModule + FormsModule // <-- import the FormsModule before binding with [(ngModel)] ], declarations: [ AppComponent diff --git a/public/docs/_examples/toh-2/e2e-spec.ts b/public/docs/_examples/toh-2/e2e-spec.ts index b5df938cd3..34f9fba573 100644 --- a/public/docs/_examples/toh-2/e2e-spec.ts +++ b/public/docs/_examples/toh-2/e2e-spec.ts @@ -128,6 +128,6 @@ function getPageElts() { return { heroes: element.all(by.css('my-app li')), selected: element(by.css('my-app li.selected')), - heroDetail: element(by.css('my-app > div, my-app > my-hero-detail > div')) + heroDetail: element(by.css('my-app > div, my-app > hero-detail > div')) }; } diff --git a/public/docs/_examples/toh-2/ts-snippets/app.component.snippets.pt2.ts b/public/docs/_examples/toh-2/ts/app/app.component.1.html similarity index 59% rename from public/docs/_examples/toh-2/ts-snippets/app.component.snippets.pt2.ts rename to public/docs/_examples/toh-2/ts/app/app.component.1.html index 801c550130..86f8228723 100644 --- a/public/docs/_examples/toh-2/ts-snippets/app.component.snippets.pt2.ts +++ b/public/docs/_examples/toh-2/ts/app/app.component.1.html @@ -1,34 +1,34 @@ -// #docregion ng-for +
  • {{hero.id}} {{hero.name}}
  • -// #enddocregion ng-for + -// #docregion heroes-styled +

    My Heroes

    -// #enddocregion heroes-styled + -// #docregion selectedHero-click +
  • - {{hero.id}} {{hero.name}} + ...
  • -// #enddocregion selectedHero-click + -// #docregion selectedHero-details +

    {{selectedHero.name}} details!

    {{selectedHero.id}}
    -// #enddocregion selectedHero-details + -// #docregion ng-if +

    {{selectedHero.name}} details!

    {{selectedHero.id}}
    @@ -37,33 +37,33 @@
    -// #enddocregion ng-if + -// #docregion hero-array-1 + heroes = HEROES; -// #enddocregion hero-array-1 + -// #docregion heroes-template-1 +

    My Heroes

    -// #enddocregion heroes-template-1 + -// #docregion heroes-ngfor-1 +
  • -// #enddocregion heroes-ngfor-1 + -// #docregion class-selected-1 + [class.selected]="hero === selectedHero" -// #enddocregion class-selected-1 + -// #docregion class-selected-2 +
  • {{hero.id}} {{hero.name}}
  • -// #enddocregion class-selected-2 + diff --git a/public/docs/_examples/toh-2/ts/plnkr.json b/public/docs/_examples/toh-2/ts/plnkr.json index 19c4e7f720..08c7b9581a 100644 --- a/public/docs/_examples/toh-2/ts/plnkr.json +++ b/public/docs/_examples/toh-2/ts/plnkr.json @@ -3,7 +3,8 @@ "basePath": "src/", "files":[ "!**/*.d.ts", - "!**/*.js" + "!**/*.js", + "!**/*.[1].*" ], "tags": ["tutorial", "tour", "heroes"] } diff --git a/public/docs/_examples/toh-3/e2e-spec.ts b/public/docs/_examples/toh-3/e2e-spec.ts index cce266dcaa..842716c5fc 100644 --- a/public/docs/_examples/toh-3/e2e-spec.ts +++ b/public/docs/_examples/toh-3/e2e-spec.ts @@ -128,6 +128,6 @@ function getPageElts() { return { heroes: element.all(by.css('my-app li')), selected: element(by.css('my-app li.selected')), - heroDetail: element(by.css('my-app > div, my-app > my-hero-detail > div')) + heroDetail: element(by.css('my-app > div, my-app > hero-detail > div')) }; } diff --git a/public/docs/_examples/toh-3/ts/app/app.component.1.html b/public/docs/_examples/toh-3/ts/app/app.component.1.html new file mode 100644 index 0000000000..bab9dda877 --- /dev/null +++ b/public/docs/_examples/toh-3/ts/app/app.component.1.html @@ -0,0 +1,12 @@ +

    {{title}}

    +

    My Heroes

    + + + + diff --git a/public/docs/_examples/toh-3/ts/app/hero-detail.component.1.ts b/public/docs/_examples/toh-3/ts/app/hero-detail.component.1.ts new file mode 100644 index 0000000000..fec477fbd7 --- /dev/null +++ b/public/docs/_examples/toh-3/ts/app/hero-detail.component.1.ts @@ -0,0 +1,35 @@ +// #docplaster +// #docregion v1 +import { Component } from '@angular/core'; + +// #enddocregion v1 +// #docregion hero-import +import { Hero } from './hero'; +// #enddocregion hero-import + +// #docregion v1 +@Component({ + selector: 'hero-detail', +// #enddocregion v1 + // #docregion template + template: ` +
    +

    {{hero.name}} details!

    +
    {{hero.id}}
    +
    + + +
    +
    + ` + // #enddocregion template +// #docregion v1 +}) +export class HeroDetailComponent { +// #enddocregion v1 +// #docregion hero + hero: Hero; +// #enddocregion hero +// #docregion v1 +} +// #enddocregion v1 diff --git a/public/docs/_examples/toh-3/ts/plnkr.json b/public/docs/_examples/toh-3/ts/plnkr.json index 086f8bd05c..829715877e 100644 --- a/public/docs/_examples/toh-3/ts/plnkr.json +++ b/public/docs/_examples/toh-3/ts/plnkr.json @@ -3,7 +3,8 @@ "basePath": "src/", "files":[ "!**/*.d.ts", - "!**/*.js" + "!**/*.js", + "!**/*.[1].*" ], "tags": ["tutorial", "tour", "heroes"] } diff --git a/public/docs/_examples/toh-3/ts/src/app/app.component.ts b/public/docs/_examples/toh-3/ts/src/app/app.component.ts index 022efc31eb..3e242914aa 100644 --- a/public/docs/_examples/toh-3/ts/src/app/app.component.ts +++ b/public/docs/_examples/toh-3/ts/src/app/app.component.ts @@ -31,7 +31,7 @@ const HEROES: Hero[] = [ {{hero.id}} {{hero.name}} - + `, // #enddocregion hero-detail-template styles: [` diff --git a/public/docs/_examples/toh-3/ts/src/app/app.module.ts b/public/docs/_examples/toh-3/ts/src/app/app.module.ts index 26b63938ad..e04b8d304b 100644 --- a/public/docs/_examples/toh-3/ts/src/app/app.module.ts +++ b/public/docs/_examples/toh-3/ts/src/app/app.module.ts @@ -3,22 +3,22 @@ import { NgModule } from '@angular/core'; import { BrowserModule } from '@angular/platform-browser'; import { FormsModule } from '@angular/forms'; -import { AppComponent } from './app.component'; +import { AppComponent } from './app.component'; // #docregion hero-detail-import import { HeroDetailComponent } from './hero-detail.component'; // #enddocregion hero-detail-import -// #docregion declarations @NgModule({ imports: [ BrowserModule, FormsModule ], +// #docregion declarations declarations: [ AppComponent, HeroDetailComponent ], +// #enddocregion declarations bootstrap: [ AppComponent ] }) export class AppModule { } -// #enddocregion declarations diff --git a/public/docs/_examples/toh-3/ts/src/app/hero-detail.component.ts b/public/docs/_examples/toh-3/ts/src/app/hero-detail.component.ts index a2f1942904..2da0892901 100644 --- a/public/docs/_examples/toh-3/ts/src/app/hero-detail.component.ts +++ b/public/docs/_examples/toh-3/ts/src/app/hero-detail.component.ts @@ -1,18 +1,12 @@ -// #docplaster // #docregion -// #docregion v1 +// #docregion import-input import { Component, Input } from '@angular/core'; +// #enddocregion import-input -// #enddocregion v1 -// #docregion hero-import import { Hero } from './hero'; -// #enddocregion hero-import - -// #docregion v1 +// #docregion template @Component({ - selector: 'my-hero-detail', -// #enddocregion v1 - // #docregion template + selector: 'hero-detail', template: `

    {{hero.name}} details!

    @@ -23,17 +17,13 @@ import { Hero } from './hero';
    ` - // #enddocregion template -// #docregion v1 }) +// #enddocregion template +// #docregion class export class HeroDetailComponent { -// #enddocregion v1 -// #docregion hero-input - @Input() // #docregion hero - hero: Hero; + @Input() hero: Hero; // #enddocregion hero -// #enddocregion hero-input -// #docregion v1 } -// #enddocregion v1 +// #docregion class + diff --git a/public/docs/_examples/toh-4/e2e-spec.ts b/public/docs/_examples/toh-4/e2e-spec.ts index 2307ba17c9..d6a223dd12 100644 --- a/public/docs/_examples/toh-4/e2e-spec.ts +++ b/public/docs/_examples/toh-4/e2e-spec.ts @@ -128,6 +128,6 @@ function getPageElts() { return { heroes: element.all(by.css('my-app li')), selected: element(by.css('my-app li.selected')), - heroDetail: element(by.css('my-app > div, my-app > my-hero-detail > div')) + heroDetail: element(by.css('my-app > div, my-app > hero-detail > div')) }; } diff --git a/public/docs/_examples/toh-4/ts/src/app/app.component.1.ts b/public/docs/_examples/toh-4/ts/src/app/app.component.1.ts index 675c7a64d0..cfddbab537 100644 --- a/public/docs/_examples/toh-4/ts/src/app/app.component.1.ts +++ b/public/docs/_examples/toh-4/ts/src/app/app.component.1.ts @@ -17,7 +17,7 @@ import { HeroService } from './hero.service.2';
    {{hero.name}}
    - + `, // #docregion providers providers: [HeroService] diff --git a/public/docs/_examples/toh-4/ts/src/app/app.component.ts b/public/docs/_examples/toh-4/ts/src/app/app.component.ts index b16acb8375..0d57acb5b0 100644 --- a/public/docs/_examples/toh-4/ts/src/app/app.component.ts +++ b/public/docs/_examples/toh-4/ts/src/app/app.component.ts @@ -20,7 +20,7 @@ import { HeroService } from './hero.service'; {{hero.id}} {{hero.name}} - + `, // #enddocregion template styles: [` diff --git a/public/docs/_examples/toh-4/ts/src/app/hero-detail.component.ts b/public/docs/_examples/toh-4/ts/src/app/hero-detail.component.ts index b36b0ae36c..865fb98da7 100644 --- a/public/docs/_examples/toh-4/ts/src/app/hero-detail.component.ts +++ b/public/docs/_examples/toh-4/ts/src/app/hero-detail.component.ts @@ -3,7 +3,7 @@ import { Component, Input } from '@angular/core'; import { Hero } from './hero'; @Component({ - selector: 'my-hero-detail', + selector: 'hero-detail', template: `

    {{hero.name}} details!

    diff --git a/public/docs/_examples/toh-5/e2e-spec.ts b/public/docs/_examples/toh-5/e2e-spec.ts index 9da4fc7765..a49f2ddb62 100644 --- a/public/docs/_examples/toh-5/e2e-spec.ts +++ b/public/docs/_examples/toh-5/e2e-spec.ts @@ -57,7 +57,7 @@ describe('Tutorial part 5', () => { selectedHero: element(by.css('my-app li.selected')), selectedHeroSubview: element(by.css('my-app my-heroes > div')), - heroDetail: element(by.css('my-app my-hero-detail > div')) + heroDetail: element(by.css('my-app hero-detail > div')) }; } diff --git a/public/docs/_examples/toh-5/ts/src/app/hero-detail.component.ts b/public/docs/_examples/toh-5/ts/src/app/hero-detail.component.ts index ad472e976e..222b6705d7 100644 --- a/public/docs/_examples/toh-5/ts/src/app/hero-detail.component.ts +++ b/public/docs/_examples/toh-5/ts/src/app/hero-detail.component.ts @@ -10,7 +10,7 @@ import { Hero } from './hero'; import { HeroService } from './hero.service'; // #docregion metadata @Component({ - selector: 'my-hero-detail', + selector: 'hero-detail', templateUrl: './hero-detail.component.html', // #enddocregion metadata, v2 styleUrls: [ './hero-detail.component.css' ] diff --git a/public/docs/_examples/toh-6/e2e-spec.ts b/public/docs/_examples/toh-6/e2e-spec.ts index c4a68aec52..80d9660263 100644 --- a/public/docs/_examples/toh-6/e2e-spec.ts +++ b/public/docs/_examples/toh-6/e2e-spec.ts @@ -63,7 +63,7 @@ describe('Tutorial part 6', () => { selectedHero: element(by.css('my-app li.selected')), selectedHeroSubview: element(by.css('my-app my-heroes > div:last-child')), - heroDetail: element(by.css('my-app my-hero-detail > div')), + heroDetail: element(by.css('my-app hero-detail > div')), searchBox: element(by.css('#search-box')), searchResults: element.all(by.css('.search-result')) diff --git a/public/docs/_examples/toh-6/ts/src/app/hero-detail.component.ts b/public/docs/_examples/toh-6/ts/src/app/hero-detail.component.ts index b3bbbd2f3d..6224f10ac1 100644 --- a/public/docs/_examples/toh-6/ts/src/app/hero-detail.component.ts +++ b/public/docs/_examples/toh-6/ts/src/app/hero-detail.component.ts @@ -8,7 +8,7 @@ import { Hero } from './hero'; import { HeroService } from './hero.service'; @Component({ - selector: 'my-hero-detail', + selector: 'hero-detail', templateUrl: './hero-detail.component.html', styleUrls: [ './hero-detail.component.css' ] }) diff --git a/public/docs/ts/latest/guide/router.jade b/public/docs/ts/latest/guide/router.jade index 0628ad62b8..bcecaf3f7d 100644 --- a/public/docs/ts/latest/guide/router.jade +++ b/public/docs/ts/latest/guide/router.jade @@ -865,7 +865,7 @@ a#heroes-functionality - Delete the `selector` (routed components don't need them). - Delete the `

    `. - Relabel the `

    ` to `

    HEROES

    `. - - Delete the `` at the bottom of the template. + - Delete the `` at the bottom of the template. - Rename the `AppComponent` class to `HeroListComponent`. - Copy the `hero-detail.component.ts` and the `hero.service.ts` files into the `heroes` subfolder. - Create a (pre-routing) `heroes.module.ts` in the heroes folder that looks like this: diff --git a/public/docs/ts/latest/guide/style-guide.jade b/public/docs/ts/latest/guide/style-guide.jade index 74e51ae8bb..312cdea64c 100644 --- a/public/docs/ts/latest/guide/style-guide.jade +++ b/public/docs/ts/latest/guide/style-guide.jade @@ -68,6 +68,8 @@ a(id='toc') to all components, services, and other symbols. This helps make the app cleaner, easier to read and maintain, and more testable. +a#rule-of-one +:marked ### _Rule of One_ #### Style 01-01 .s-rule.do diff --git a/public/docs/ts/latest/tutorial/_data.json b/public/docs/ts/latest/tutorial/_data.json index 6d1c63bb12..03b5fa2545 100644 --- a/public/docs/ts/latest/tutorial/_data.json +++ b/public/docs/ts/latest/tutorial/_data.json @@ -7,33 +7,33 @@ }, "toh-pt1": { "title": "The Hero Editor", - "intro": "We build a simple hero editor.", + "intro": "Build a simple hero editor.", "nextable": true }, "toh-pt2": { "title": "Master/Detail", - "intro": "We build a master/detail page with a list of heroes.", + "intro": "Build a master/detail page with a list of heroes.", "nextable": true }, "toh-pt3": { "title": "Multiple Components", - "intro": "We refactor the master/detail view into separate components.", + "intro": "Refactor the master/detail view into separate components.", "nextable": true }, "toh-pt4": { "title": "Services", - "intro": "We create a reusable service to manage our hero data calls.", + "intro": "Create a reusable service to manage the hero data calls.", "nextable": true }, "toh-pt5": { "title": "Routing", - "intro": "We add the Angular Router and learn to navigate among the views.", + "intro": "Add the Angular component router and learn to navigate among the views.", "nextable": true }, "toh-pt6": { "title": "HTTP", "subtitle": "Getting and saving data", - "intro": "We convert our service and components to use Angular's HTTP service.", + "intro": "Convert the service and components to use Angular's HTTP service.", "nextable": true } } diff --git a/public/docs/ts/latest/tutorial/index.jade b/public/docs/ts/latest/tutorial/index.jade index cb392d9aa5..8a30a55656 100644 --- a/public/docs/ts/latest/tutorial/index.jade +++ b/public/docs/ts/latest/tutorial/index.jade @@ -2,80 +2,82 @@ block includes include ../_util-fns :marked - Our grand plan for this tutorial is to build an app to help a staffing agency manage its stable of heroes. - Even heroes need to find work. + The grand plan for this tutorial is to build an app that helps a staffing agency manage its stable of heroes. - Of course we'll only make a little progress in this tutorial. What we do build will - have many of the features we expect to find in a full-blown, data-driven application: acquiring and displaying + The Tour of Heroes app covers the core fundamentals of Angular. You'll build a basic app that + has many of the features you'd expect to find in a full-blown, data-driven app: acquiring and displaying a list of heroes, editing a selected hero's detail, and navigating among different views of heroic data. - The Tour of Heroes covers the core fundamentals of Angular. - We’ll use built-in directives to show/hide elements and display lists of hero data. - We’ll create a component to display hero details and another to show an array of heroes. - We'll use one-way data binding for read-only data. We'll add editable fields to update a model - with two-way data binding. We'll bind component methods to user events like key strokes and clicks. - We’ll learn to select a hero from a master list and edit that hero in the details view. We'll - format data with pipes. We'll create a shared service to assemble our heroes. And we'll use routing to navigate among different views and their components. + You'll use built-in directives to show and hide elements and display lists of hero data. + You'll create components to display hero details and show an array of heroes. + You'll use one-way data binding for read-only data. You'll add editable fields to update a model + with two-way data binding. You'll bind component methods to user events, like keystrokes and clicks. + You'll enable users to select a hero from a master list and edit that hero in the details view. You'll + format data with pipes. You'll create a shared service to assemble the heroes. + And you'll use routing to navigate among different views and their components. + - We’ll learn enough core Angular to get started and gain confidence that - Angular can do whatever we need it to do. - We'll be covering a lot of ground at an introductory level but we’ll find plenty of links - to chapters with greater depth. + You'll learn enough core Angular to get started and gain confidence that + Angular can do whatever you need it to do. + You'll cover a lot of ground at an introductory level, and you'll find many links + to pages with greater depth. + + When you're done with this tutorial, the app will look like this . - Run the . .l-main-section :marked - ## The End Game + ## The end game - Here's a visual idea of where we're going in this tour, beginning with the "Dashboard" - view and our most heroic heroes: + Here's a visual idea of where this tutorial leads, beginning with the "Dashboard" + view and the most heroic heroes: figure.image-display img(src='/resources/images/devguide/toh/heroes-dashboard-1.png' alt="Output of heroes dashboard") :marked - Above the dashboard are two links ("Dashboard" and "Heroes"). - We could click them to navigate between this Dashboard and a Heroes view. + You can click the two links above the dashboard ("Dashboard" and "Heroes") + to navigate between this Dashboard view and a Heroes view. - Instead we click the dashboard hero named "Magneta" and the router takes us to a "Hero Details" view - of that hero where we can change the hero's name. + If you click the dashboard hero "Magneta," the router opens a "Hero Details" view + where you can change the hero's name. figure.image-display img(src='/resources/images/devguide/toh/hero-details-1.png' alt="Details of hero in app") :marked - Clicking the "Back" button would return us to the "Dashboard". - Links at the top can take us to either of the main views. - We'll click "Heroes". The app takes to the "Heroes" master list view. + Clicking the "Back" button returns you to the Dashboard. + Links at the top take you to either of the main views. + If you click "Heroes," the app displays the "Heroes" master list view. figure.image-display img(src='/resources/images/devguide/toh/heroes-list-2.png' alt="Output of heroes list app") +// CF: The ability to add heroes isn't shown in the images or discussed in this page. Should that be added? :marked - We click a different hero and the readonly mini-detail beneath the list reflects our new choice. + When you click a different hero name, the read-only mini detail beneath the list reflects the new choice. - We click the "View Details" button to drill into the - editable details of our selected hero. + You can click the "View Details" button to drill into the + editable details of the selected hero. - The following diagram captures all of our navigation options. + The following diagram captures all of the navigation options. figure.image-display img(src='/resources/images/devguide/toh/nav-diagram.png' alt="View navigations") :marked - Here's our app in action + Here's the app in action: figure.image-display img(src='/resources/images/devguide/toh/toh-anim.gif' alt="Tour of Heroes in Action") .l-main-section :marked - ## Up Next + ## Up next - We’ll build this Tour of Heroes together, step by step. - We'll motivate each step with a requirement that we've - met in countless applications. Everything has a reason. + You'll build the Tour of Heroes app, step by step. + Each step is motivated with a requirement that you've likely + met in many applications. Everything has a reason. - And we’ll meet many of the core fundamentals of Angular along the way. + Along the way, you'll become familiar with many of the core fundamentals of Angular. diff --git a/public/docs/ts/latest/tutorial/toh-pt1.jade b/public/docs/ts/latest/tutorial/toh-pt1.jade index 1a6e5e05d8..676c74cb38 100644 --- a/public/docs/ts/latest/tutorial/toh-pt1.jade +++ b/public/docs/ts/latest/tutorial/toh-pt1.jade @@ -2,11 +2,10 @@ include ../_util-fns :marked ## Setup to develop locally - Real application development takes place in a local development environment like your machine. - Follow the [setup](../guide/setup.html) instructions for creating a new project - named - after which the file structure should look like this: + named . + + The file structure should look like this: .filetree .file angular-tour-of-heroes @@ -22,172 +21,159 @@ include ../_util-fns .file styles.css .file systemjs.config.js .file tsconfig.json - .file node_modules ... + .file node_modules ... .file package.json :marked - When we're done with this first episode, the app runs like this . + When you're done with this page, the app should look like this . +a#keep-transpiling +:marked ## Keep the app transpiling and running - We want to start the TypeScript compiler, have it watch for changes, and start our server. - Do this by entering the following command in the terminal window. - + Enter the following command in the terminal window: code-example(language="sh" class="code-shell"). npm start :marked - This command runs the compiler in watch mode, starts the server, launches the app in a browser, - and keeps the app running while we continue to build the Tour of Heroes. + This command runs the TypeScript compiler in "watch mode", recompiling automatically when the code changes. + The command simultaneously launches the app in a browser and refreshes the browser when the code changes. + + You can keep building the Tour of Heroes without pausing to recompile or refresh the browser. .l-main-section :marked - ## Show our Hero - We want to display Hero data in our app + ## Show the hero + Add two properties to the `AppComponent`: a `title` property for the app name and a `hero` property + for a hero named "Windstorm." - Update the `AppComponent` so it has two properties:   a `title` property for the application name and a `hero` property - for a hero named "Windstorm". - - +makeExample('toh-1/ts-snippets/app.component.snippets.pt1.ts', 'app-component-1', 'src/app/app.component.ts (AppComponent class)')(format=".") + +makeExample('toh-1/ts/app/app.component.1.ts', 'app-component-1', 'app.component.ts (AppComponent class)')(format=".") :marked - Now update the template in the `@Component` decoration with data bindings to these new properties. + Now update the template in the `@Component` decorator with data bindings to these new properties. - +makeExample('toh-1/ts-snippets/app.component.snippets.pt1.ts', 'show-hero') + +makeExample('toh-1/ts/app/app.component.1.ts', 'show-hero', 'app.component.ts (@Component)')(format='.') :marked - The browser should refresh and display our title and hero. + The browser refreshes and displays the title and hero name. + + The double curly braces are Angular's *interpolation binding* syntax. + These interpolation bindings present the component's `title` and `hero` property values, + as strings, inside the HTML header tags. - The double curly braces tell our app to read the `title` and `hero` properties from the component and render them. - This is the "interpolation" form of one-way data binding. .l-sub-section :marked - Learn more about interpolation in the [Displaying Data chapter](../guide/displaying-data.html). + Read more about interpolation in the [Displaying Data](../guide/displaying-data.html) page. + :marked ### Hero object - At the moment, our hero is just a name. Our hero needs more properties. - Let's convert the `hero` from a literal string to a class. + The hero needs more properties. + Convert the `hero` from a literal string to a class. Create a `Hero` class with `id` and `name` properties. - For now put this near the top of the `app.component.ts` file, just below the import statement. + Add these properties near the top of the `app.component.ts` file, just below the import statement. +makeExample('toh-1/ts/src/app/app.component.ts', 'hero-class-1', 'src/app/app.component.ts (Hero class)')(format=".") :marked - Now that we have a `Hero` class, let’s refactor our component’s `hero` property to be of type `Hero`. - Then initialize it with an id of `1` and the name, "Windstorm". + In the `Hero` class, refactor the component's `hero` property to be of type `Hero`, + then initialize it with an `id` of `1` and the name `Windstorm`. +makeExample('toh-1/ts/src/app/app.component.ts', 'hero-property-1', 'src/app/app.component.ts (hero property)')(format=".") :marked - Because we changed the hero from a string to an object, - we update the binding in the template to refer to the hero’s `name` property. + Because you changed the hero from a string to an object, + update the binding in the template to refer to the hero's `name` property. -+makeExample('toh-1/ts-snippets/app.component.snippets.pt1.ts', 'show-hero-2') ++makeExample('toh-1/ts/app/app.component.1.ts', 'show-hero-2') :marked - The browser refreshes and continues to display our hero’s name. + The browser refreshes and continues to display the hero's name. - ### Adding more HTML - Displaying a name is good, but we want to see all of our hero’s properties. - We’ll add a `
    ` for our hero’s `id` property and another `
    ` for our hero’s `name`. + ### Adding HTML with multi-line template strings -+makeExample('toh-1/ts-snippets/app.component.snippets.pt1.ts', 'show-hero-properties') -:marked - Uh oh, our template string is getting long. We better take care of that to avoid the risk of making a typo in the template. + To show all of the hero's properties, + add a `
    ` for the hero's `id` property and another `
    ` for the hero's `name`. + To keep the template readable, place each `
    ` on its own line. - ### Multi-line template strings + The backticks around the component template let you put the `

    `, `

    `, and `
    ` elements on their own lines, + thanks to the template literals feature in ES2015 and TypeScript. For more information, see + Template literals. - We could make a more readable template with string concatenation - but that gets ugly fast, it is harder to read, and - it is easy to make a spelling error. Instead, - let’s take advantage of the template strings feature - in ES2015 and TypeScript to maintain our sanity. - Change the quotes around the template to back-ticks and - put the `

    `, `

    ` and `
    ` elements on their own lines. - -+makeExample('toh-1/ts-snippets/app.component.snippets.pt1.ts', 'multi-line-strings', 'src/app/app.component.ts (AppComponent\'s template)') - - .callout.is-important - header A back-tick is not a single quote - :marked - **Be careful!** A back-tick (`) looks a lot like a single quote ('). - It's actually a completely different character. - Back-ticks can do more than demarcate a string. - Here we use them in a limited way to spread the template over multiple lines. - Everything between the back-ticks at the beginning and end of the template - is part of a single template string. ++makeExample('toh-1/ts/app/app.component.1.ts', 'multi-line-strings', 'app.component.ts (AppComponent\'s template)')(format='.') .l-main-section :marked - ## Editing Our Hero + ## Edit the hero name - We want to be able to edit the hero name in a textbox. + Users should be able to edit the hero name in an `` textbox. + The textbox should both _display_ the hero's `name` property + and _update_ that property as the user types. - Refactor the hero name `