diff --git a/public/_includes/_footer.jade b/public/_includes/_footer.jade
index efccce5223..21113616e9 100644
--- a/public/_includes/_footer.jade
+++ b/public/_includes/_footer.jade
@@ -7,7 +7,7 @@ if version && language
else
- var styleguide = "/docs/ts/latest/styleguide.html"
-.main-footer
+div(class="main-footer" data-swiftype-index="false")
nav.background-midnight.grid-fluid
.c3.main-footer-branding
diff --git a/public/_includes/_head-include.jade b/public/_includes/_head-include.jade
index 463ce9a786..0f736acee0 100644
--- a/public/_includes/_head-include.jade
+++ b/public/_includes/_head-include.jade
@@ -1,14 +1,21 @@
- var language = current.path[1]
- var version = ''
+- var section = ''
if current.path[2]
- var version = current.path[2].replace(/\_+/gm, ".")
+if current.path[3]
+ - var section = current.path[3].toUpperCase()
+
+
if language == 'js'
if language == 'dart'
if title == "Angular"
title #{title}
+else if section
+ title #{title} - #{language} - #{section}
else if language
title #{title} - #{language}
else
diff --git a/public/_includes/_main-nav.jade b/public/_includes/_main-nav.jade
index 6d76e7ef2e..5a128f4587 100644
--- a/public/_includes/_main-nav.jade
+++ b/public/_includes/_main-nav.jade
@@ -1,7 +1,7 @@
- var language = current.path[1] || 'ts'
- if (language !== 'ts' || language !== 'js' || language !== 'dart') { language = 'ts'; }
-nav(class="main-nav l-pinned-top l-layer-5", scroll-y-offset-element)
+nav(data-swiftype-index="false" class="main-nav l-pinned-top l-layer-5", scroll-y-offset-element)
h1 Angular by Google
button(class="main-nav-button main-nav-mobile-trigger l-right" aria-label="查看菜单" ng-click="appCtrl.toggleMainMenu($event)" md-button) 网站菜单
diff --git a/public/docs/_examples/.editorconfig b/public/docs/_examples/.editorconfig
deleted file mode 100644
index f2abacf6d3..0000000000
--- a/public/docs/_examples/.editorconfig
+++ /dev/null
@@ -1,20 +0,0 @@
-# http://editorconfig.org
-root = true
-
-[*]
-charset = utf-8
-indent_style = space
-indent_size = 2
-end_of_line = lf
-insert_final_newline = true
-trim_trailing_whitespace = true
-
-
-[*.md]
-max_line_length = 0
-trim_trailing_whitespace = false
-
-# Indentation override
-#[lib/**.js]
-#[{package.json,.travis.yml}]
-#[**/**.js]
diff --git a/public/docs/_examples/dependency-injection/ts/index.html b/public/docs/_examples/dependency-injection/ts/index.html
index 74f8ed8894..ce65fac8b7 100644
--- a/public/docs/_examples/dependency-injection/ts/index.html
+++ b/public/docs/_examples/dependency-injection/ts/index.html
@@ -1,7 +1,7 @@
-
+
Dependency Injection
@@ -19,8 +19,7 @@
System.import('app').catch(function(err){ console.error(err); });
-
-
+
Loading my-app ...
Loading my-providers ...
diff --git a/public/docs/_examples/lifecycle-hooks/ts/app/counter.component.ts b/public/docs/_examples/lifecycle-hooks/ts/app/counter.component.ts
index 71167ab791..8efd1fbd52 100644
--- a/public/docs/_examples/lifecycle-hooks/ts/app/counter.component.ts
+++ b/public/docs/_examples/lifecycle-hooks/ts/app/counter.component.ts
@@ -1,7 +1,7 @@
// #docregion
import {
Component, Input,
- OnChanges, SimpleChange,
+ OnChanges, SimpleChanges,
} from '@angular/core';
import { LoggerService } from './logger.service';
@@ -22,7 +22,7 @@ export class MyCounterComponent implements OnChanges {
@Input() counter: number;
changeLog: string[] = [];
- ngOnChanges(changes: {[propertyName: string]: SimpleChange}) {
+ ngOnChanges(changes: SimpleChanges) {
// Empty the changeLog whenever counter goes to zero
// hint: this is a way to respond programmatically to external value changes.
@@ -36,7 +36,6 @@ export class MyCounterComponent implements OnChanges {
let prev = JSON.stringify(chng.previousValue); // first time is {}; after is integer
this.changeLog.push(`counter: currentValue = ${cur}, previousValue = ${prev}`);
}
-
}
/***************************************/
diff --git a/public/docs/_examples/lifecycle-hooks/ts/app/on-changes.component.ts b/public/docs/_examples/lifecycle-hooks/ts/app/on-changes.component.ts
index 4c83d6f864..da3aa70716 100644
--- a/public/docs/_examples/lifecycle-hooks/ts/app/on-changes.component.ts
+++ b/public/docs/_examples/lifecycle-hooks/ts/app/on-changes.component.ts
@@ -2,7 +2,7 @@
// #docregion
import {
Component, Input, OnChanges,
- SimpleChange, ViewChild
+ SimpleChanges, ViewChild
} from '@angular/core';
class Hero {
@@ -33,7 +33,7 @@ export class OnChangesComponent implements OnChanges {
changeLog: string[] = [];
// #docregion ng-on-changes
- ngOnChanges(changes: {[propertyName: string]: SimpleChange}) {
+ ngOnChanges(changes: SimpleChanges) {
for (let propName in changes) {
let chng = changes[propName];
let cur = JSON.stringify(chng.currentValue);
diff --git a/public/docs/_examples/lifecycle-hooks/ts/app/peek-a-boo.component.ts b/public/docs/_examples/lifecycle-hooks/ts/app/peek-a-boo.component.ts
index 57b421c7f8..dcee428753 100644
--- a/public/docs/_examples/lifecycle-hooks/ts/app/peek-a-boo.component.ts
+++ b/public/docs/_examples/lifecycle-hooks/ts/app/peek-a-boo.component.ts
@@ -7,7 +7,7 @@ import {
OnChanges,
OnDestroy,
OnInit,
- SimpleChange
+ SimpleChanges
} from '@angular/core';
import { Component, Input } from '@angular/core';
import { LoggerService } from './logger.service';
@@ -51,7 +51,7 @@ export class PeekABooComponent extends PeekABoo implements
}
// only called for/if there is an @input variable set by parent.
- ngOnChanges(changes: {[propertyName: string]: SimpleChange}) {
+ ngOnChanges(changes: SimpleChanges) {
let changesMsgs: string[] = [];
for (let propName in changes) {
if (propName === 'name') {
diff --git a/public/docs/_examples/toh-5/dart/lib/dashboard_component.1.html b/public/docs/_examples/toh-5/dart/lib/dashboard_component.1.html
new file mode 100644
index 0000000000..0c556b8de0
--- /dev/null
+++ b/public/docs/_examples/toh-5/dart/lib/dashboard_component.1.html
@@ -0,0 +1,9 @@
+
+Top Heroes
+
diff --git a/public/docs/_examples/toh-5/dart/lib/dashboard_component.css b/public/docs/_examples/toh-5/dart/lib/dashboard_component.css
index f6263074f0..d850f074b5 100644
--- a/public/docs/_examples/toh-5/dart/lib/dashboard_component.css
+++ b/public/docs/_examples/toh-5/dart/lib/dashboard_component.css
@@ -1,6 +1,12 @@
/* #docregion */
[class*='col-'] {
float: left;
+ text-decoration: none;
+ padding-right: 20px;
+ padding-bottom: 20px;
+}
+[class*='col-']:last-of-type {
+ padding-right: 0;
}
*, *:after, *:before {
-webkit-box-sizing: border-box;
@@ -10,12 +16,8 @@
h3 {
text-align: center; margin-bottom: 0;
}
-[class*='col-'] {
- padding-right: 20px;
- padding-bottom: 20px;
-}
-[class*='col-']:last-of-type {
- padding-right: 0;
+h4 {
+ position: relative;
}
.grid {
margin: 0;
@@ -32,9 +34,6 @@ h3 {
background-color: #607D8B;
border-radius: 2px;
}
-h4 {
- position: relative;
-}
.module:hover {
background-color: #EEE;
cursor: pointer;
diff --git a/public/docs/_examples/toh-5/dart/lib/dashboard_component.dart b/public/docs/_examples/toh-5/dart/lib/dashboard_component.dart
index 8b2f6fe4af..bc2293cec1 100644
--- a/public/docs/_examples/toh-5/dart/lib/dashboard_component.dart
+++ b/public/docs/_examples/toh-5/dart/lib/dashboard_component.dart
@@ -1,14 +1,13 @@
// #docplaster
// #docregion
+// #docregion imports
import 'dart:async';
import 'package:angular2/core.dart';
-// #docregion import-router
-import 'package:angular2/router.dart';
-// #enddocregion import-router
import 'hero.dart';
import 'hero_service.dart';
+// #enddocregion imports
@Component(
selector: 'my-dashboard',
@@ -24,24 +23,14 @@ class DashboardComponent implements OnInit {
List heroes;
// #docregion ctor
- final Router _router;
final HeroService _heroService;
- DashboardComponent(this._heroService, this._router);
+ DashboardComponent(this._heroService);
// #enddocregion ctor
Future ngOnInit() async {
heroes = (await _heroService.getHeroes()).skip(1).take(4).toList();
}
-
- // #docregion gotoDetail
- void gotoDetail(Hero hero) {
- var link = [
- 'HeroDetail',
- {'id': hero.id.toString()}
- ];
- _router.navigate(link);
- }
-// #enddocregion gotoDetail
}
+// #enddocregion component
diff --git a/public/docs/_examples/toh-5/dart/lib/dashboard_component.html b/public/docs/_examples/toh-5/dart/lib/dashboard_component.html
index 7133c10ada..49e77c460c 100644
--- a/public/docs/_examples/toh-5/dart/lib/dashboard_component.html
+++ b/public/docs/_examples/toh-5/dart/lib/dashboard_component.html
@@ -2,10 +2,10 @@
Top Heroes
diff --git a/public/docs/_examples/toh-5/dart/lib/dashboard_component_2.dart b/public/docs/_examples/toh-5/dart/lib/dashboard_component_2.dart
deleted file mode 100644
index c5304f572a..0000000000
--- a/public/docs/_examples/toh-5/dart/lib/dashboard_component_2.dart
+++ /dev/null
@@ -1,26 +0,0 @@
-// #docplaster
-// #docregion imports
-import 'dart:async';
-
-import 'package:angular2/core.dart';
-
-import 'hero.dart';
-import 'hero_service.dart';
-// #enddocregion imports
-
-// #docregion component
-@Component(
- selector: 'my-dashboard',
- templateUrl: 'dashboard_component.html')
-class DashboardComponent implements OnInit {
- List heroes;
- final HeroService _heroService;
-
- DashboardComponent(this._heroService);
-
- Future ngOnInit() async {
- heroes = (await _heroService.getHeroes()).skip(1).take(4).toList();
- }
-
- gotoDetail(Hero hero) {/* not implemented yet */}
-}
diff --git a/public/docs/_examples/toh-5/e2e-spec.ts b/public/docs/_examples/toh-5/e2e-spec.ts
index 1bb398b7f7..9da4fc7765 100644
--- a/public/docs/_examples/toh-5/e2e-spec.ts
+++ b/public/docs/_examples/toh-5/e2e-spec.ts
@@ -1,4 +1,4 @@
-'use strict'; // necessary for es6 output in node
+'use strict'; // necessary for es6 output in node
import { browser, element, by, ElementFinder } from 'protractor';
import { promise } from 'selenium-webdriver';
@@ -42,16 +42,16 @@ describe('Tutorial part 5', () => {
beforeAll(() => browser.get(''));
function getPageElts() {
- let hrefElts = element.all(by.css('my-app a'));
+ let navElts = element.all(by.css('my-app nav a'));
return {
- hrefs: hrefElts,
+ navElts: navElts,
- myDashboardHref: hrefElts.get(0),
+ myDashboardHref: navElts.get(0),
myDashboard: element(by.css('my-app my-dashboard')),
topHeroes: element.all(by.css('my-app my-dashboard > div h4')),
- myHeroesHref: hrefElts.get(1),
+ myHeroesHref: navElts.get(1),
myHeroes: element(by.css('my-app my-heroes')),
allHeroes: element.all(by.css('my-app my-heroes li')),
selectedHero: element(by.css('my-app li.selected')),
@@ -73,7 +73,7 @@ describe('Tutorial part 5', () => {
const expectedViewNames = ['Dashboard', 'Heroes'];
it(`has views ${expectedViewNames}`, () => {
- let viewNames = getPageElts().hrefs.map((el: ElementFinder) => el.getText());
+ let viewNames = getPageElts().navElts.map((el: ElementFinder) => el.getText());
expect(viewNames).toEqual(expectedViewNames);
});
diff --git a/public/docs/_examples/toh-5/ts/app/dashboard.component.1.html b/public/docs/_examples/toh-5/ts/app/dashboard.component.1.html
new file mode 100644
index 0000000000..0c556b8de0
--- /dev/null
+++ b/public/docs/_examples/toh-5/ts/app/dashboard.component.1.html
@@ -0,0 +1,9 @@
+
+Top Heroes
+
diff --git a/public/docs/_examples/toh-5/ts/app/dashboard.component.2.ts b/public/docs/_examples/toh-5/ts/app/dashboard.component.2.ts
deleted file mode 100644
index 4e0e8553bc..0000000000
--- a/public/docs/_examples/toh-5/ts/app/dashboard.component.2.ts
+++ /dev/null
@@ -1,27 +0,0 @@
-// #docplaster
-// #docregion imports
-import { Component, OnInit } from '@angular/core';
-
-import { Hero } from './hero';
-import { HeroService } from './hero.service';
-// #enddocregion imports
-
-@Component({
- moduleId: module.id,
- selector: 'my-dashboard',
- templateUrl: 'dashboard.component.html'
-})
-// #docregion component
-export class DashboardComponent implements OnInit {
-
- heroes: Hero[] = [];
-
- constructor(private heroService: HeroService) { }
-
- ngOnInit(): void {
- this.heroService.getHeroes()
- .then(heroes => this.heroes = heroes.slice(1, 5));
- }
-
- gotoDetail(hero: Hero): void { /* not implemented yet */}
-}
diff --git a/public/docs/_examples/toh-5/ts/app/dashboard.component.css b/public/docs/_examples/toh-5/ts/app/dashboard.component.css
index f6263074f0..dc7fb7ce06 100644
--- a/public/docs/_examples/toh-5/ts/app/dashboard.component.css
+++ b/public/docs/_examples/toh-5/ts/app/dashboard.component.css
@@ -1,22 +1,26 @@
/* #docregion */
[class*='col-'] {
float: left;
-}
-*, *:after, *:before {
- -webkit-box-sizing: border-box;
- -moz-box-sizing: border-box;
- box-sizing: border-box;
-}
-h3 {
- text-align: center; margin-bottom: 0;
-}
-[class*='col-'] {
padding-right: 20px;
padding-bottom: 20px;
}
[class*='col-']:last-of-type {
padding-right: 0;
}
+a {
+ text-decoration: none;
+}
+*, *:after, *:before {
+ -webkit-box-sizing: border-box;
+ -moz-box-sizing: border-box;
+ box-sizing: border-box;
+}
+h3 {
+ text-align: center; margin-bottom: 0;
+}
+h4 {
+ position: relative;
+}
.grid {
margin: 0;
}
@@ -24,16 +28,13 @@ h3 {
width: 25%;
}
.module {
- padding: 20px;
- text-align: center;
- color: #eee;
- max-height: 120px;
- min-width: 120px;
- background-color: #607D8B;
- border-radius: 2px;
-}
-h4 {
- position: relative;
+ padding: 20px;
+ text-align: center;
+ color: #eee;
+ max-height: 120px;
+ min-width: 120px;
+ background-color: #607D8B;
+ border-radius: 2px;
}
.module:hover {
background-color: #EEE;
@@ -47,15 +48,15 @@ h4 {
padding-right: 20px;
}
@media (max-width: 600px) {
- .module {
- font-size: 10px;
- max-height: 75px; }
+ .module {
+ font-size: 10px;
+ max-height: 75px; }
}
@media (max-width: 1024px) {
- .grid {
- margin: 0;
- }
- .module {
- min-width: 60px;
- }
+ .grid {
+ margin: 0;
+ }
+ .module {
+ min-width: 60px;
+ }
}
diff --git a/public/docs/_examples/toh-5/ts/app/dashboard.component.html b/public/docs/_examples/toh-5/ts/app/dashboard.component.html
index 67ac6aa459..49e77c460c 100644
--- a/public/docs/_examples/toh-5/ts/app/dashboard.component.html
+++ b/public/docs/_examples/toh-5/ts/app/dashboard.component.html
@@ -2,10 +2,10 @@
Top Heroes
diff --git a/public/docs/_examples/toh-5/ts/app/dashboard.component.ts b/public/docs/_examples/toh-5/ts/app/dashboard.component.ts
index f72a149c8c..cb5cfc5b82 100644
--- a/public/docs/_examples/toh-5/ts/app/dashboard.component.ts
+++ b/public/docs/_examples/toh-5/ts/app/dashboard.component.ts
@@ -1,13 +1,13 @@
// #docplaster
// #docregion
+// #docregion imports
import { Component, OnInit } from '@angular/core';
-// #docregion import-router
-import { Router } from '@angular/router';
-// #enddocregion import-router
import { Hero } from './hero';
import { HeroService } from './hero.service';
- // #docregion metadata
+// #enddocregion imports
+
+// #docregion metadata
@Component({
moduleId: module.id,
selector: 'my-dashboard',
@@ -19,27 +19,18 @@ import { HeroService } from './hero.service';
// #docregion metadata
})
// #enddocregion metadata
-// #docregion component
+// #docregion class
export class DashboardComponent implements OnInit {
heroes: Hero[] = [];
// #docregion ctor
- constructor(
- private router: Router,
- private heroService: HeroService) {
- }
+ constructor(private heroService: HeroService) { }
// #enddocregion ctor
ngOnInit(): void {
this.heroService.getHeroes()
.then(heroes => this.heroes = heroes.slice(1, 5));
}
-
- // #docregion gotoDetail
- gotoDetail(hero: Hero): void {
- let link = ['/detail', hero.id];
- this.router.navigate(link);
- }
- // #enddocregion gotoDetail
}
+// #enddocregion class
diff --git a/public/docs/_examples/toh-5/ts/app/heroes.component.ts b/public/docs/_examples/toh-5/ts/app/heroes.component.ts
index cbcb598ac2..1f2290c853 100644
--- a/public/docs/_examples/toh-5/ts/app/heroes.component.ts
+++ b/public/docs/_examples/toh-5/ts/app/heroes.component.ts
@@ -40,8 +40,10 @@ export class HeroesComponent implements OnInit {
this.selectedHero = hero;
}
+ // #docregion gotoDetail
gotoDetail(): void {
this.router.navigate(['/detail', this.selectedHero.id]);
}
+ // #enddocregion gotoDetail
// #docregion renaming
}
diff --git a/public/docs/_examples/toh-6/dart/lib/dashboard_component.css b/public/docs/_examples/toh-6/dart/lib/dashboard_component.css
index f6263074f0..dc7fb7ce06 100644
--- a/public/docs/_examples/toh-6/dart/lib/dashboard_component.css
+++ b/public/docs/_examples/toh-6/dart/lib/dashboard_component.css
@@ -1,22 +1,26 @@
/* #docregion */
[class*='col-'] {
float: left;
-}
-*, *:after, *:before {
- -webkit-box-sizing: border-box;
- -moz-box-sizing: border-box;
- box-sizing: border-box;
-}
-h3 {
- text-align: center; margin-bottom: 0;
-}
-[class*='col-'] {
padding-right: 20px;
padding-bottom: 20px;
}
[class*='col-']:last-of-type {
padding-right: 0;
}
+a {
+ text-decoration: none;
+}
+*, *:after, *:before {
+ -webkit-box-sizing: border-box;
+ -moz-box-sizing: border-box;
+ box-sizing: border-box;
+}
+h3 {
+ text-align: center; margin-bottom: 0;
+}
+h4 {
+ position: relative;
+}
.grid {
margin: 0;
}
@@ -24,16 +28,13 @@ h3 {
width: 25%;
}
.module {
- padding: 20px;
- text-align: center;
- color: #eee;
- max-height: 120px;
- min-width: 120px;
- background-color: #607D8B;
- border-radius: 2px;
-}
-h4 {
- position: relative;
+ padding: 20px;
+ text-align: center;
+ color: #eee;
+ max-height: 120px;
+ min-width: 120px;
+ background-color: #607D8B;
+ border-radius: 2px;
}
.module:hover {
background-color: #EEE;
@@ -47,15 +48,15 @@ h4 {
padding-right: 20px;
}
@media (max-width: 600px) {
- .module {
- font-size: 10px;
- max-height: 75px; }
+ .module {
+ font-size: 10px;
+ max-height: 75px; }
}
@media (max-width: 1024px) {
- .grid {
- margin: 0;
- }
- .module {
- min-width: 60px;
- }
+ .grid {
+ margin: 0;
+ }
+ .module {
+ min-width: 60px;
+ }
}
diff --git a/public/docs/_examples/toh-6/dart/lib/dashboard_component.dart b/public/docs/_examples/toh-6/dart/lib/dashboard_component.dart
index d23b7f543d..ac71e10e17 100644
--- a/public/docs/_examples/toh-6/dart/lib/dashboard_component.dart
+++ b/public/docs/_examples/toh-6/dart/lib/dashboard_component.dart
@@ -18,20 +18,11 @@ import 'hero_search_component.dart';
class DashboardComponent implements OnInit {
List heroes;
- final Router _router;
final HeroService _heroService;
- DashboardComponent(this._heroService, this._router);
+ DashboardComponent(this._heroService);
Future ngOnInit() async {
heroes = (await _heroService.getHeroes()).skip(1).take(4).toList();
}
-
- void gotoDetail(Hero hero) {
- var link = [
- 'HeroDetail',
- {'id': hero.id.toString()}
- ];
- _router.navigate(link);
- }
}
diff --git a/public/docs/_examples/toh-6/dart/lib/dashboard_component.html b/public/docs/_examples/toh-6/dart/lib/dashboard_component.html
index fe1ee585f6..db8546ccd2 100644
--- a/public/docs/_examples/toh-6/dart/lib/dashboard_component.html
+++ b/public/docs/_examples/toh-6/dart/lib/dashboard_component.html
@@ -1,10 +1,10 @@
Top Heroes
diff --git a/public/docs/_examples/toh-6/e2e-spec.ts b/public/docs/_examples/toh-6/e2e-spec.ts
index 814fa2004c..c4a68aec52 100644
--- a/public/docs/_examples/toh-6/e2e-spec.ts
+++ b/public/docs/_examples/toh-6/e2e-spec.ts
@@ -1,4 +1,4 @@
-'use strict'; // necessary for es6 output in node
+'use strict'; // necessary for es6 output in node
import { browser, element, by, ElementFinder, ElementArrayFinder } from 'protractor';
import { promise } from 'selenium-webdriver';
@@ -48,16 +48,16 @@ describe('Tutorial part 6', () => {
beforeAll(() => browser.get(''));
function getPageElts() {
- let hrefElts = element.all(by.css('my-app a'));
+ let navElts = element.all(by.css('my-app nav a'));
return {
- hrefs: hrefElts,
+ navElts: navElts,
- myDashboardHref: hrefElts.get(0),
+ myDashboardHref: navElts.get(0),
myDashboard: element(by.css('my-app my-dashboard')),
topHeroes: element.all(by.css('my-app my-dashboard > div h4')),
- myHeroesHref: hrefElts.get(1),
+ myHeroesHref: navElts.get(1),
myHeroes: element(by.css('my-app my-heroes')),
allHeroes: element.all(by.css('my-app my-heroes li')),
selectedHero: element(by.css('my-app li.selected')),
@@ -82,7 +82,7 @@ describe('Tutorial part 6', () => {
const expectedViewNames = ['Dashboard', 'Heroes'];
it(`has views ${expectedViewNames}`, () => {
- let viewNames = getPageElts().hrefs.map((el: ElementFinder) => el.getText());
+ let viewNames = getPageElts().navElts.map((el: ElementFinder) => el.getText());
expect(viewNames).toEqual(expectedViewNames);
});
diff --git a/public/docs/_examples/toh-6/ts/app/dashboard.component.css b/public/docs/_examples/toh-6/ts/app/dashboard.component.css
index ce6e963a5f..dc7fb7ce06 100644
--- a/public/docs/_examples/toh-6/ts/app/dashboard.component.css
+++ b/public/docs/_examples/toh-6/ts/app/dashboard.component.css
@@ -1,23 +1,26 @@
-/* #docplaster */
/* #docregion */
[class*='col-'] {
float: left;
-}
-*, *:after, *:before {
- -webkit-box-sizing: border-box;
- -moz-box-sizing: border-box;
- box-sizing: border-box;
-}
-h3 {
- text-align: center; margin-bottom: 0;
-}
-[class*='col-'] {
padding-right: 20px;
padding-bottom: 20px;
}
[class*='col-']:last-of-type {
padding-right: 0;
}
+a {
+ text-decoration: none;
+}
+*, *:after, *:before {
+ -webkit-box-sizing: border-box;
+ -moz-box-sizing: border-box;
+ box-sizing: border-box;
+}
+h3 {
+ text-align: center; margin-bottom: 0;
+}
+h4 {
+ position: relative;
+}
.grid {
margin: 0;
}
@@ -25,16 +28,13 @@ h3 {
width: 25%;
}
.module {
- padding: 20px;
- text-align: center;
- color: #eee;
- max-height: 120px;
- min-width: 120px;
- background-color: #607D8B;
- border-radius: 2px;
-}
-h4 {
- position: relative;
+ padding: 20px;
+ text-align: center;
+ color: #eee;
+ max-height: 120px;
+ min-width: 120px;
+ background-color: #607D8B;
+ border-radius: 2px;
}
.module:hover {
background-color: #EEE;
@@ -48,16 +48,15 @@ h4 {
padding-right: 20px;
}
@media (max-width: 600px) {
- .module {
- font-size: 10px;
- max-height: 75px; }
+ .module {
+ font-size: 10px;
+ max-height: 75px; }
}
@media (max-width: 1024px) {
- .grid {
- margin: 0;
- }
- .module {
- min-width: 60px;
- }
+ .grid {
+ margin: 0;
+ }
+ .module {
+ min-width: 60px;
+ }
}
-/* #enddocregion */
diff --git a/public/docs/_examples/toh-6/ts/app/dashboard.component.html b/public/docs/_examples/toh-6/ts/app/dashboard.component.html
index fe1ee585f6..db8546ccd2 100644
--- a/public/docs/_examples/toh-6/ts/app/dashboard.component.html
+++ b/public/docs/_examples/toh-6/ts/app/dashboard.component.html
@@ -1,10 +1,10 @@
Top Heroes
diff --git a/public/docs/_examples/toh-6/ts/app/dashboard.component.ts b/public/docs/_examples/toh-6/ts/app/dashboard.component.ts
index 92df6569b1..a66ec3b89b 100644
--- a/public/docs/_examples/toh-6/ts/app/dashboard.component.ts
+++ b/public/docs/_examples/toh-6/ts/app/dashboard.component.ts
@@ -1,6 +1,5 @@
// #docregion , search
import { Component, OnInit } from '@angular/core';
-import { Router } from '@angular/router';
import { Hero } from './hero';
import { HeroService } from './hero.service';
@@ -15,18 +14,10 @@ import { HeroService } from './hero.service';
export class DashboardComponent implements OnInit {
heroes: Hero[] = [];
- constructor(
- private router: Router,
- private heroService: HeroService) {
- }
+ constructor(private heroService: HeroService) { }
ngOnInit(): void {
this.heroService.getHeroes()
.then(heroes => this.heroes = heroes.slice(1, 5));
}
-
- gotoDetail(hero: Hero): void {
- let link = ['/detail', hero.id];
- this.router.navigate(link);
- }
}
diff --git a/public/docs/_includes/_side-nav.jade b/public/docs/_includes/_side-nav.jade
index 89a956de69..626ee1271b 100644
--- a/public/docs/_includes/_side-nav.jade
+++ b/public/docs/_includes/_side-nav.jade
@@ -60,7 +60,7 @@
- if (language !== 'ts' || language !== 'js' || language !== 'dart') { language = 'ts'; }
-nav(class="sidenav l-pinned-left l-layer-4 l-offset-nav" ng-class="appCtrl.showDocsNav ? 'is-visible' : ''")
+nav(class="sidenav l-pinned-left l-layer-4 l-offset-nav" data-swiftype-index="false" ng-class="appCtrl.showDocsNav ? 'is-visible' : ''")
// SEARCH BAR
header.sidenav-search.st-input-wrapper
.st-input-inner
diff --git a/public/docs/ts/latest/tutorial/toh-pt5.jade b/public/docs/ts/latest/tutorial/toh-pt5.jade
index 6abe6c17f4..e93eba044a 100644
--- a/public/docs/ts/latest/tutorial/toh-pt5.jade
+++ b/public/docs/ts/latest/tutorial/toh-pt5.jade
@@ -625,21 +625,14 @@ block redirect-vs-use-as-default
使用下列内容创建文件:
-+makeExcerpt('app/dashboard.component.html')
++makeExample('app/dashboard.component.1.html', '', 'app/dashboard.component.html')
:marked
We use `*ngFor` once again to iterate over a list of heroes and display their names.
We added extra `` elements to help with styling later in this chapter.
我们又一次使用`*ngFor`来在英雄列表上迭代,并显示它们的名字。
- 还添加了一个额外的`
`元素,来帮助稍后的美化工作。
-
- There's a `(click)` binding to a `gotoDetail` method we haven't written yet and
- we're displaying a list of heroes that we don't have.
- We have work to do, starting with those heroes.
-
- 这里的`(click)`绑定到了`gotoDetail`方法,但我们还没实现它。而且我们也还没有要显示的英雄列表数据。
- 我们有活儿干了,就从这些英雄列表开始吧。
+ 还添加了一个额外的`
`元素,来帮助稍后的美化工作。
### Share the *HeroService*
@@ -668,7 +661,7 @@ block redirect-vs-use-as-default
打开
dashboard.component.ts文件,并把必备的`import`语句加进去。
-+makeExcerpt('app/dashboard.component.2.ts','imports')
++makeExcerpt('app/dashboard.component.ts','imports')
:marked
We need `OnInit` interface because we'll initialize the heroes in the `ngOnInit` method as we've done before.
@@ -681,7 +674,7 @@ block redirect-vs-use-as-default
我们现在就实现`DashboardComponent`类,像这样:
-+makeExcerpt('app/dashboard.component.2.ts (class)', 'component')
++makeExcerpt('app/dashboard.component.ts (class)', 'class')
:marked
We've seen this kind of logic before in the `HeroesComponent`:
@@ -700,10 +693,9 @@ block redirect-vs-use-as-default
* 在Angular的`ngOnInit`生命周期钩子里面调用服务来获得英雄列表。
- The noteworthy differences: we cherry-pick four heroes (2nd, 3rd, 4th, and 5th)
- and stub the `gotoDetail` method until we're ready to implement it.
+ In this dashboard we cherry-pick four heroes (2nd, 3rd, 4th, and 5th) with the `Array.slice` method.
- 值得注意的区别是:我们提取了四个英雄(第2、3、4、5个),暂时隔离`gotoDetail`方法直到时机成熟。
+ 值得注意的区别是:我们用`Array.slice`方法提取了四个英雄(第2、3、4、5个)。
Refresh the browser and see four heroes in the new dashboard.
@@ -974,8 +966,7 @@ block extract-id
修改模板,添加这个按钮以提醒我们还要做更多的改进,
并把模板移到独立的
hero-detail.component.html文件中去。
-
-+makeExample('app/hero-detail.component.html')
++makeExample('app/hero-detail.component.html')(format='.')
:marked
We update the component metadata with a `moduleId` and a `templateUrl` pointing to the template file that we just created.
@@ -1003,51 +994,27 @@ block extract-id
When a user selects a hero in the dashboard, the app should navigate to the `HeroDetailComponent` to view and edit the selected hero.
当用户从仪表盘中选择了一位英雄时,本应用要导航到`HeroDetailComponent`以查看和编辑所选的英雄。
+
+ Although the dashboard heroes are presented as button-like blocks, they should behave like anchor tags.
+ When hovering over a hero block, the target URL should display in the browser status bar
+ and the user should be able to copy the link or open the hero detail view in a new tab.
- In the dashboard template we bound each hero's click event to the `gotoDetail` method, passing along the selected `hero` entity.
+ To achieve this effect, reopen the `dashboard.component.html` and replace the repeated `
` tags
+ with `
` tags. The opening `` tag looks like this:
- 在仪表盘模板中,我们把每个英雄的click事件都绑定成`gotoDetail`方法,并且传入选中的这个`hero`实体对象。
-
-+makeExample('toh-5/ts/app/dashboard.component.html','click', 'app/dashboard.component.html (click绑定)')(format=".")
++makeExample('app/dashboard.component.html', 'click', 'app/dashboard.component.html (repeated tag)')
:marked
- We stubbed the `gotoDetail` method when we rewrote the `DashboardComponent`.
- Now we give it a real implementation.
+ Notice the `[routerLink]` binding.
- 当初我们重写`DashboardComponent`的时候,`gotoDetail`还是一个“桩方法”。
- 现在,我们给它一个真正的实现。
-
-+makeExcerpt('app/dashboard.component.ts','gotoDetail')
-
-:marked
- The `gotoDetail` method navigates in two steps:
-
- `gotoDetail`方法分两步完成导航:
-
- 1. Set a route *link parameters !{_array}*
-
- 1. 生成路由的 *链接参数数组*
-
- 1. Pass the !{_array} to the router's navigate method
-
- 1. 把这个数组传给路由器的navigate方法。
-
- For navigation, we wrote router links as *link
- parameters !{_array}s* in the [`AppComponent`
- template](#router-links). Those link parameters
- !{_array}s had only one element, the !{_pathVsName} of the
- destination route.
-
- 我们为导航在[`AppComponent`的模板](#router-links)中生成导航链接as *link
- parameters !{_array}s*。这些链接 parameters
- !{_array}只有一个元素:目标路由的路径。
-
- This link parameters !{_array} has two elements, the ***!{_pathVsName}*** of
- the destination route and a ***route parameter*** with
- an `id` field set to the value of the selected hero's `id`.
-
- 这个链接参数数组有两个元素:目标路由的***路径(path)***和一个***路由参数对象***,其中包括一个`id`字段,它的取值是所选英雄的`id`。
+ In the top level navigation in the [`AppComponent`
+ template](#router-links) has router links set to fixed !{_pathVsName}s of the
+ destination routes, "/dashboard" and "/heroes".
+ This time, we're binding to an expression containing a **link parameters !{_array}**.
+ The !{_array} has two elements, the ***!{_pathVsName}*** of
+ the destination route and a ***route parameter*** set to the value of the current hero's `id`.
+
The two !{_array} items align with the ***!{_pathVsName}*** and ***:id***
token in the parameterized hero detail route definition we added to
`!{_appRoutingTsVsAppComp}` earlier in the chapter:
@@ -1057,17 +1024,6 @@ block extract-id
- var _file = _docsFor == 'dart' ? 'app/app.component.ts' : 'app/app.module.3.ts'
+makeExcerpt(_file + ' (hero detail)', 'hero-detail')
-:marked
- The `DashboardComponent` doesn't have the router yet. We obtain it in the usual way:
- import the `router` reference and inject it in the constructor (along with the `HeroService`):
-
- `DashboardComponent`还没有路由器。我们使用常规的方式为它加上路由:
- `import` `router`对象的引用,并且把它注入到构造函数中(就像`HeroService`那样):
-
-+makeExcerpt('app/dashboard.component.ts ()','import-router', '')
-
-+makeExcerpt('app/dashboard.component.ts', 'ctor', '')
-
:marked
Refresh the browser and select a hero from the dashboard; the app should navigate directly to that hero’s details.
@@ -1181,7 +1137,7 @@ block extract-id
我们要做的是将详情组建移动到它自己的视图,并在用户决定编辑一个英雄时导航到它。
- Delete the `` at the top (forgot about it during the `AppComponent`-to-`HeroesComponent` conversion).
+ Delete the `` at the top (we forgot about it during the `AppComponent`-to-`HeroesComponent` conversion).
删除顶部的``(在从`AppComponent`转到`HeroesComponent`期间可以先忘掉它)。
@@ -1195,7 +1151,7 @@ block extract-id
这里我们不再展示完整的`HeroDetailComponent`了。
我们要在它自己的页面中显示英雄详情,并像我们在仪表盘中所做的那样路由到它。
- But we'll throw in a small twist for variety.
+ We'll throw in a small twist for variety.
We are keeping the "master/detail" style but shrinking the detail to a "mini", read-only version.
When the user selects a hero from the list, we *don't* go to the detail page.
We show a *mini-detail* on *this* page instead and make the user click a button to navigate to the *full detail *page.
@@ -1296,25 +1252,25 @@ block heroes-component-cleanup
+makeExcerpt('app/heroes.component.ts (revised metadata)', 'metadata')
:marked
- Now we can see what's going on as we update the component class along the same lines as the dashboard:
+ ### Update the _HeroesComponent_ class.
- 现在,我们一下就明白该怎么像仪表盘中那样更新组件类了:
+ The `HeroesComponent` navigates to the `HeroesDetailComponent` in response to a button click.
+ The button's _click_ event is bound to a `gotoDetail` method that navigates _imperatively_
+ by telling the router where to go.
- 1. Import the `router`
-
- 1. 导入`router`
+ This approach requires some changes to the component class:
+ 1. Import the `router` from the Angular router library
1. Inject the `router` in the constructor (along with the `HeroService`)
-
- 1. 把`router`注入到构造函数中(就像`HeroService`那样)
-
- 1. Implement the `gotoDetail` method by calling the `router.navigate` method with a two-part hero-detail link parameters !{_array}.
-
- 1. 实现`gotoDetail`方法:以`HeroDetail`和*链接参数数组*为参数调用`router.navigate`方法。
-
- Here's the revised component class:
-
- 下面是修改过的组件类:
+ 1. Implement `gotoDetail` by calling the `router.navigate` method
+
++makeExcerpt('app/heroes.component.ts', 'gotoDetail')
+:marked
+ Note that we're passing a two-element **link parameters !{_array}**
+ — a path and the route parameter — to
+ the `router.navigate` method just as we did in the `[routerLink]` binding
+ back in the `DashboardComponent`
+ Here's the fully revised `HeroesComponent` class:
+makeExcerpt('app/heroes.component.ts', 'class')
diff --git a/scripts/config/bad-code-excerpt-skip-patterns.txt b/scripts/config/bad-code-excerpt-skip-patterns.txt
index b66e9ce758..731cbff933 100644
--- a/scripts/config/bad-code-excerpt-skip-patterns.txt
+++ b/scripts/config/bad-code-excerpt-skip-patterns.txt
@@ -5,3 +5,4 @@
/ts/latest/guide/style-guide.html # https://github.com/angular/angular.io/issues/2123
/ts/latest/guide/upgrade.html # In a transient state until RC6 - @filipe.silva
/[jt]s/.*/api/forms/index/NG_VALIDATORS-let.html # RC6 contains broken example tags
+/dart/latest/tutorial/toh-pt5.html