-
-
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 300f3065e0..cd43e03b86 100644
--- a/public/docs/_examples/toh-5/ts/app/heroes.component.ts
+++ b/public/docs/_examples/toh-5/ts/app/heroes.component.ts
@@ -6,21 +6,18 @@ import { Router } from '@angular/router-deprecated';
import { Hero } from './hero';
import { HeroService } from './hero.service';
-// #docregion metadata
-// #docregion heroes-component-renaming
+// #docregion heroes-component-renaming, metadata
@Component({
selector: 'my-heroes',
-// #enddocregion heroes-component-renaming
+ // #enddocregion heroes-component-renaming
templateUrl: 'app/heroes.component.html',
styleUrls: ['app/heroes.component.css']
-// #docregion heroes-component-renaming
+ // #docregion heroes-component-renaming
})
-// #enddocregion heroes-component-renaming
-// #enddocregion metadata
-// #docregion class
-// #docregion heroes-component-renaming
+// #enddocregion heroes-component-renaming, metadata
+// #docregion class, heroes-component-renaming
export class HeroesComponent implements OnInit {
-// #enddocregion heroes-component-renaming
+ // #enddocregion heroes-component-renaming
heroes: Hero[];
selectedHero: Hero;
@@ -41,8 +38,5 @@ export class HeroesComponent implements OnInit {
gotoDetail() {
this.router.navigate(['HeroDetail', { id: this.selectedHero.id }]);
}
-// #docregion heroes-component-renaming
+ // #docregion heroes-component-renaming
}
-// #enddocregion heroes-component-renaming
-// #enddocregion class
-// #enddocregion
diff --git a/public/docs/_examples/toh-5/ts/app/mock-heroes.ts b/public/docs/_examples/toh-5/ts/app/mock-heroes.ts
index ddd36d7868..69afde3d34 100644
--- a/public/docs/_examples/toh-5/ts/app/mock-heroes.ts
+++ b/public/docs/_examples/toh-5/ts/app/mock-heroes.ts
@@ -13,4 +13,3 @@ export var HEROES: Hero[] = [
{id: 19, name: 'Magma'},
{id: 20, name: 'Tornado'}
];
-// #enddocregion
diff --git a/public/docs/_examples/toh-5/ts/index.html b/public/docs/_examples/toh-5/ts/index.html
index 93fa8d4889..4df64edba1 100644
--- a/public/docs/_examples/toh-5/ts/index.html
+++ b/public/docs/_examples/toh-5/ts/index.html
@@ -1,7 +1,7 @@
-
+
diff --git a/public/docs/_examples/toh-5/ts/styles.1.css b/public/docs/_examples/toh-5/ts/styles.1.css
index 5b77b74d1c..dee6d5b8ca 100644
--- a/public/docs/_examples/toh-5/ts/styles.1.css
+++ b/public/docs/_examples/toh-5/ts/styles.1.css
@@ -1,5 +1,11 @@
-/* #docregion */
-h2 {
+/* #docregion toh-excerpt */
+/* Master Styles */
+h1 {
+ color: #369;
+ font-family: Arial, Helvetica, sans-serif;
+ font-size: 250%;
+}
+h2, h3 {
color: #444;
font-family: Arial, Helvetica, sans-serif;
font-weight: lighter;
@@ -11,23 +17,7 @@ body, input[text], button {
color: #888;
font-family: Cambria, Georgia;
}
-button {
- font-family: Arial;
- background-color: #eee;
- border: none;
- padding: 5px 10px;
- border-radius: 4px;
- cursor: pointer;
- cursor: hand;
-}
-button:hover {
- background-color: #cfd8dc;
-}
-button:disabled {
- background-color: #eee;
- color: #aaa;
- cursor: auto;
-}
+/* . . . */
/* everywhere else */
* {
font-family: Arial, Helvetica, sans-serif;
diff --git a/public/docs/_examples/toh-6/ts/app/hero-detail.component.ts b/public/docs/_examples/toh-6/ts/app/hero-detail.component.ts
index 73ea334fc2..bce249dcc1 100644
--- a/public/docs/_examples/toh-6/ts/app/hero-detail.component.ts
+++ b/public/docs/_examples/toh-6/ts/app/hero-detail.component.ts
@@ -1,6 +1,8 @@
// #docplaster
-// #docregion
+// #docregion, variables-imports
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
+
+// #enddocregion variables-imports
import { RouteParams } from '@angular/router-deprecated';
import { Hero } from './hero';
@@ -11,11 +13,13 @@ import { HeroService } from './hero.service';
templateUrl: 'app/hero-detail.component.html',
styleUrls: ['app/hero-detail.component.css']
})
+// #docregion variables-imports
export class HeroDetailComponent implements OnInit {
@Input() hero: Hero;
@Output() close = new EventEmitter();
error: any;
navigated = false; // true if navigated here
+ // #enddocregion variables-imports
constructor(
private heroService: HeroService,
diff --git a/public/docs/_examples/webpack/e2e-spec.ts b/public/docs/_examples/webpack/e2e-spec.ts
new file mode 100644
index 0000000000..8e706597f5
--- /dev/null
+++ b/public/docs/_examples/webpack/e2e-spec.ts
@@ -0,0 +1,18 @@
+///
+describe('QuickStart E2E Tests', function () {
+
+ let expectedMsg = 'Hello from Angular 2 App with Webpack';
+
+ beforeEach(function () {
+ browser.get('');
+ });
+
+ it(`should display: ${expectedMsg}`, function () {
+ expect(element(by.css('h1')).getText()).toEqual(expectedMsg);
+ });
+
+ it('should display an image', function () {
+ expect(element(by.css('img')).isPresent()).toBe(true);
+ });
+
+});
diff --git a/public/docs/_examples/webpack/ts/example-config.json b/public/docs/_examples/webpack/ts/example-config.json
index e69de29bb2..9e587f892f 100644
--- a/public/docs/_examples/webpack/ts/example-config.json
+++ b/public/docs/_examples/webpack/ts/example-config.json
@@ -0,0 +1,4 @@
+{
+ "build": "build:webpack",
+ "run": "http-server:cli"
+}
diff --git a/public/docs/ts/latest/guide/style-guide.jade b/public/docs/ts/latest/guide/style-guide.jade
index e485a15883..c25e9dd7d1 100644
--- a/public/docs/ts/latest/guide/style-guide.jade
+++ b/public/docs/ts/latest/guide/style-guide.jade
@@ -126,11 +126,10 @@ a(id='toc')
我们遵循[单一职责原则](https:\/\/en.wikipedia.org/wiki/Single_responsibility_principle)来创建的所有组件、服务和其它标志等。这样能帮助我们把应用程序弄的干净整洁,易于阅读、维护和测试。
- ### Rule of One
- ### 单一法则
-
- #### Style 01-01
- #### 风格 01-01
+ ### Rule of One
+ ### 单一法则
+ #### Style 01-01
+ #### 风格 01-01
.s-rule.do
:marked
**Do** define one thing (e.g. service or component) per file.
@@ -202,12 +201,13 @@ a(href="#toc") 回到顶部
.l-main-section
:marked
- ### Small Functions
- ### 小函数
-
- #### Style 01-02
- #### 风格01-02
.s-rule.do
+ ### Small Functions
+ ### 小函数
+
+ #### Style 01-02
+ #### 风格01-02
+
:marked
**Do** define small functions
@@ -263,11 +263,10 @@ a(href="#toc") 回到顶部
.l-main-section
:marked
- ### General Naming Guidelines
- ### 总体命名指导原则
-
- #### Style 02-01
- #### 风格02-01
+ ### General Naming Guidelines
+ ### 总体命名知道原则
+ #### Style 02-01
+ #### 风格02-01
.s-rule.do
:marked
@@ -307,11 +306,10 @@ a(href="#toc") 回到顶部
.l-main-section
:marked
- ### Separate File Names with Dots and Dashes
- ### 使用点和横杠来分隔文件名字
-
- #### Style 02-02
- #### 风格02-02
+ ### Separate File Names with Dots and Dashes
+ ### 使用点和横杠来分隔文件名
+ #### Style 02-02
+ #### 风格02-02
.s-rule.do
:marked
@@ -376,11 +374,10 @@ a(href="#toc") 回到顶部
.l-main-section
:marked
- ### Components and Directives
- ### 组件和指令命名
-
- #### Style 02-03
- #### 风格02-03
+ ### Components and Directives
+ ### 组件与指令命名
+ #### Style 02-03
+ #### 风格02-03
.s-rule.do
:marked
@@ -478,11 +475,10 @@ a(href="#toc") 回到顶部
.l-main-section
:marked
- ### Service Names
- ### 服务名
-
- #### Style 02-04
- #### 风格02-04
+ ### Service Names
+ ### 服务名
+ #### Style 02-04
+ #### 风格02-04
.s-rule.do
:marked
@@ -563,11 +559,10 @@ a(href="#toc") 回到顶部
.l-main-section
:marked
- ### Bootstrapping
- ### 引导程序
-
- #### Style 02-05
- #### 风格02-05
+ ### Bootstrapping
+ ### 引导
+ #### Style 02-05
+ #### 风格02-05
.s-rule.do
:marked
@@ -600,11 +595,10 @@ a(href="#toc") 回到顶部
.l-main-section
:marked
- ### Directive Selectors
- ### 指令的选择器
-
- #### Style 02-06
- #### 风格02-06
+ ### Directive Selectors
+ ### 指令的选择器
+ #### Style 02-06
+ #### 风格02-06
.s-rule.do
:marked
@@ -631,11 +625,10 @@ a(href="#toc") 回到顶部
.l-main-section
:marked
- ### Custom Prefix for Components
- ### 为组件自定义前缀
-
- #### Style 02-07
- #### 风格02-07
+ ### Custom Prefix for Components
+ ### 为组件自定义前缀
+ #### Style 02-07
+ #### 风格02-07
.s-rule.do
:marked
@@ -680,11 +673,10 @@ a(href="#toc") 回到顶部
:marked
:marked
- ### Custom Prefix for Directives
- ### 为指令添加自定义前缀
-
- #### Style 02-08
- #### 风格02-08
+ ### Custom Prefix for Directives
+ ### 为指令添加自定义前缀
+ #### Style 02-08
+ #### 风格02-08
.s-rule.do
:marked
@@ -716,11 +708,10 @@ a(href="#toc") 回到顶部
.l-main-section
:marked
- ### Pipe Names
- ### 管道名
-
- #### Style 02-09
- #### 风格02-09
+ ### Pipe Names
+ ### 管道名
+ #### Style 02-09
+ #### 风格02-09
.s-rule.do
:marked
@@ -769,11 +760,9 @@ a(href="#toc") 回到顶部
.l-main-section
:marked
- ### Unit Test File Names
- ### 单元测试文件命名
-
- #### Style 02-10
- #### 风格02-10
+ ### Unit Test File Names
+ ### 单元测试文件名
+ #### 风格02-10
.s-rule.do
:marked
@@ -856,11 +845,10 @@ a(href="#toc") 回到顶部
.l-main-section
:marked
- ### End to End Test File Names
- ### 端到端测试文件命名
-
- #### Style 02-11
- #### 风格02-11
+ ### End to End Test File Names
+ ### 端到端测试文件名
+ #### Style 02-11
+ #### 风格02-11
.s-rule.do
:marked
@@ -921,11 +909,8 @@ a(href="#toc") 回到顶部
.l-main-section
:marked
- ### Classes
- ### 类
-
- #### Style 03-01
- #### 风格03-01
+ ### 类
+ #### 风格03-01
.s-rule.do
:marked
@@ -958,11 +943,10 @@ a(href="#toc") 回到顶部
.l-main-section
:marked
- ### Constants
- ### 常量
-
- #### Style 03-02
- #### 风格03-02
+ ### Constants
+ ### 常量
+ #### Style 03-02
+ #### 风格03-02
.s-rule.do
:marked
@@ -995,11 +979,10 @@ a(href="#toc") 回到顶部
.l-main-section
:marked
- ### Interfaces
- ### 接口
-
- #### Style 03-03
- #### 风格03-03
+ ### Interfaces
+ ### 接口
+ #### Style 03-03
+ #### 风格03-03
.s-rule.do
:marked
@@ -1032,11 +1015,10 @@ a(href="#toc") 回到顶部
.l-main-section
:marked
- ### Properties and Methods
- ### 属性和方法名
-
- #### Style 03-04
- #### 风格03-04
+ ### Properties and Methods
+ ### 属性和方法
+ #### Style 03-04
+ #### 样式03-04
.s-rule.do
:marked
@@ -1081,11 +1063,10 @@ a(href="#toc") 回到顶部
.l-main-section
:marked
- ### Import Destructuring Spacing
- ### 导入语句解构表达式中的空格
-
- #### Style 03-05
- #### 风格03-05
+ ### Import Destructuring Spacing
+ ### 导入语句解构表达式中的空格
+ #### Style 03-05
+ #### 风格03-05
.s-rule.do
:marked
@@ -1111,11 +1092,10 @@ a(href="#toc") 回到顶部
.l-main-section
:marked
- ### Import Line Spacing
- ### 导入语句中的空行
-
- #### Style 03-06
- #### 风格03-06
+ ### Import Line Spacing
+ ### 导入语句中的空行
+ #### Style 03-06
+ #### 风格03-06
.s-rule.do
:marked
@@ -1179,11 +1159,9 @@ a(href="#toc") 回到顶部
.l-main-section
:marked
- ### LIFT
- ### LIFT (定位`L`ocate、识别`I`dentity、平面化`F`lattest、尝试`T`ry遵循不重复自己DRY - Do Not Repeat Yourself约定)
-
- #### Style 04-01
- #### 风格04-01
+ ### LIFT
+ #### Style 04-01
+ #### 风格04-01
.s-rule.do
:marked
@@ -1208,11 +1186,11 @@ a(href="#toc") 回到顶部
.l-main-section
:marked
- ### Locate
- ### 定位
-
- #### Style 04-02
- #### 风格04-02
+ ### Locate
+ ### 定位
+
+ #### Style 04-02
+ #### 风格04-02
.s-rule.do
:marked
@@ -1232,11 +1210,10 @@ a(href="#toc") 回到顶部
.l-main-section
:marked
- ### Identify
- ### 识别
-
- #### Style 04-03
- #### 风格04-03
+ ### Identify
+ ### 识别
+ #### Style 04-03
+ #### 风格04-03
.s-rule.do
:marked
@@ -1275,11 +1252,10 @@ a(href="#toc") 回到顶部
.l-main-section
:marked
- ### Flat
- ### 平面化
-
- #### Style 04-04
- #### 风格04-04
+ ### Flat
+ ### 平面化
+ #### Style 04-04
+ #### 风格04-04
.s-rule.do
:marked
@@ -1305,11 +1281,10 @@ a(href="#toc") 回到顶部
.l-main-section
:marked
- ### T-DRY (Try to be DRY)
- ### T-DRY(尝试遵循不重复自己DRY的约定)
-
- #### Style 04-05
- #### 风格04-05
+ ### T-DRY (Try to be DRY)
+ ### T-DRY (尝试遵循不重复自己DRY的约定)
+ #### Style 04-05
+ #### 风格04-05
.s-rule.do
:marked
@@ -1335,11 +1310,10 @@ a(href="#toc") 回到顶部
.l-main-section
:marked
- ### Overall Structural Guidelines
- ### 总体结构指导原则
-
- #### Style 04-06
- #### 风格04-06
+ ### Overall Structural Guidelines
+ ### 总体结构指导原则
+ #### Style 04-06
+ #### 风格04-06
.s-rule.do
:marked
@@ -1422,11 +1396,10 @@ a(href="#toc") 回到顶部
.l-main-section
:marked
- ### Shared Folder
- ### 共享目录
-
- #### Style 04-07
- #### 风格04-07
+ ### Shared Folder
+ ### 共享目录
+ #### Style 04-07
+ #### 风格04-07
.s-rule.do
:marked
@@ -1495,11 +1468,10 @@ a(href="#toc") 回到顶部
.l-main-section
:marked
- ### Folders-by-Feature Structure
- ### 根据特性划分的目录结构
-
- #### Style 04-08
- #### 风格04-08
+ ### Folders-by-Feature Structure
+ ### 根据特性划分的目录结构
+ #### Style 04-08
+ #### 风格04-08
.s-rule.do
:marked
@@ -1586,11 +1558,10 @@ a(href="#toc") 回到顶部
.l-main-section
:marked
- ### Layout Components
- ### 布局组件
-
- #### Style 04-09
- #### 风格04-09
+ ### Layout Components
+ ### 布局组件
+ #### Style 04-09
+ #### 风格04-09
.s-rule.do
:marked
@@ -1650,11 +1621,10 @@ a(href="#toc") 回到顶部
.l-main-section
:marked
- ### Create and Import Barrels
- ### 新建和导入封装桶
-
- #### Style 04-10
- #### 风格04-10
+ ### Create and Import Barrels
+ ### 创建和导入封装桶
+ #### Style 04-10
+ #### 风格04-10
.s-rule.consider
:marked
@@ -1760,11 +1730,10 @@ a(href="#toc") 回到顶部
.l-main-section
:marked
- ### Lazy Loaded Folders
- ### 惰性加载目录
-
- #### Style 04-11
- #### 风格04-11
+ ### Lazy Loaded Folders
+ ### 惰性加载目录
+ #### Style 04-11
+ #### 风格04-11
A distinct application feature or workflow may be *lazy loaded* or *loaded on demand* rather than when the application starts.
一个独特的应用程序特性或者工作流可能被**惰性加载**或**按需加载**,而非在应用程序启动时就全部加载。
@@ -1788,11 +1757,10 @@ a(href="#toc") 回到顶部
.l-main-section
:marked
- ### Prefix Lazy Loaded Folders with +
- ### 为惰性加载目录名字加前缀+
-
- #### Style 04-12
- #### 风格04-12
+ ### Prefix Lazy Loaded Folders with +
+ ### 为惰性加载目录名字加前缀+
+ #### Style 04-12
+ #### 样式04-12
.s-rule.do
:marked
@@ -1836,11 +1804,10 @@ a(href="#toc") 回到顶部
.l-main-section
:marked
- ### Never Directly Import Lazy Loaded Folders
- ### 决不直接导入惰性加载目录
-
- #### Style 04-13
- #### 风格
+ ### Never Directly Import Lazy Loaded Folders
+ ### 决不直接导入惰性加载目录
+ #### Style 04-13
+ #### 风格04-13
.s-rule.avoid
:marked
@@ -1863,11 +1830,10 @@ a(href="#toc") 回到顶部
.l-main-section
:marked
- ### Lazy Loaded Folders May Import From a Parent
+ ### Lazy Loaded Folders May Import From a Parent
### 惰性加载目录可以导入父级
-
- #### Style 04-14
- #### 风格04-14
+ #### Style 04-14
+ #### 样式04-14
.s-rule.do
:marked
@@ -1891,11 +1857,10 @@ a(href="#toc") 回到顶部
.l-main-section
:marked
- ### Use Component Router to Lazy Load
- ### 使用组件路由器来惰性加载
-
- #### Style 04-15
- #### 风格04-15
+ ### Use Component Router to Lazy Load
+ ### 使用组件路由器来惰性加载
+ #### Style 04-15
+ #### 风格04-15
.s-rule.do
:marked
@@ -1917,12 +1882,11 @@ a(href="#toc") 回到顶部
.l-main-section
:marked
## Components
- ## 组件
- ### Components Selector Naming
- ### 组件选择器命名
-
- #### Style 05-02
- #### 风格05-02
+
+ ### Components Selector Naming
+ ### 组件选择器命名
+ #### Style 05-02
+ #### 风格05-02
.s-rule.do
:marked
@@ -1953,11 +1917,10 @@ a(href="#toc") 回到顶部
.l-main-section
:marked
- ### Components as Elements
- ### 将组件当做元素
-
- #### Style 05-03
- #### 风格05-03
+ ### Components as Elements
+ ### 把组件当做元素
+ #### Style 05-03
+ #### 风格05-03
.s-rule.do
:marked
@@ -2003,11 +1966,10 @@ a(href="#toc") 回到顶部
.l-main-section
:marked
- ### Extract Template and Styles to Their Own Files
- ### 把模板和样式提取到它们自己的文件
-
- #### Style 05-04
- #### 风格05-04
+ ### Extract Template and Styles to Their Own Files
+ ### 把模板和样式提取到它们自己的文件
+ #### Style 05-04
+ #### 风格05-04
.s-rule.do
:marked
@@ -2059,11 +2021,10 @@ a(href="#toc") 回到顶部
.l-main-section
:marked
- ### Decorate Input and Output Properties Inline
- ### 内联Input和Output属性装饰
-
- #### Style 05-12
- #### 风格05-12
+ ### Decorate Input and Output Properties Inline
+ ### 内联Input和Output属性装饰器
+ #### Style 05-12
+ #### 风格05-12
.s-rule.do
:marked
@@ -2113,11 +2074,10 @@ a(href="#toc") 回到顶部
.l-main-section
:marked
- ### Avoid Renaming Inputs and Outputs
- ### 避免重命名输入和输出
-
- #### Style 05-13
- #### 风格05-13
+ ### Avoid Renaming Inputs and Outputs
+ ### 避免重命名输入和输出
+ #### Style 05-13
+ #### 风格05-13
.s-rule.avoid
:marked
@@ -2152,11 +2112,10 @@ a(href="#toc") 回到顶部
.l-main-section
:marked
- ### Member Sequence
- ### 成员顺序
-
- #### Style 05-14
- #### 风格05-14
+ ### Member Sequence
+ ### 成员顺序
+ #### Style 05-14
+ #### 风格05-14
.s-rule.do
:marked
@@ -2188,12 +2147,11 @@ a(href="#toc") 回到顶部
.l-main-section
:marked
- ### Put Logic in Services
- ### 把逻辑放到服务里
-
- #### Style 05-15
- #### 风格05-15
-
+ ### Put Logic in Services
+ ### 把逻辑放到服务里
+ #### Style 05-15
+ #### 风格05-15
+
.s-rule.do
:marked
**Do** limit logic in a component to only that required for the view. All other logic should be delegated to services.
@@ -2243,11 +2201,10 @@ a(href="#toc") 回到顶部
.l-main-section
:marked
- ### Don't Prefix Output Properties
- ### 不要给输出属性加前缀
-
- #### Style 05-16
- #### 风格05-16
+ ### Don't Prefix Output Properties
+ ### 不要给输出属性加前缀
+ #### Style 05-16
+ #### 风格05-16
.s-rule.do
:marked
@@ -2293,11 +2250,9 @@ a(href="#toc") 回到顶部
.l-main-section
:marked
- ### Put Presentation Logic in the Component Class
- ### 把展示逻辑放到组件类里
-
- #### Style 05-17
- #### 风格05-17
+ ### 把展示逻辑放到组件类里
+ #### Style 05-17
+ #### 风格05-17
.s-rule.do
:marked
@@ -2339,11 +2294,10 @@ a(href="#toc") 回到顶部
.l-main-section
:marked
- ### Use Directives to Enhance an Existing Element
- ### 使用指令来加强已有元素
-
- #### Style 06-01
- #### 风格06-01
+ ### Use Directives to Enhance an Existing Element
+ ### 使用指令来加强已有元素
+ #### Style 06-01
+ #### 风格06-01
.s-rule.do
:marked
@@ -2375,11 +2329,10 @@ a(href="#toc") 回到顶部
.l-main-section
:marked
- ### Use HostListener and HostBinding Class Decorators
- ### 使用HostListener和HostBinding类装饰器
-
- #### Style 06-03
- #### 风格06-03
+ ### Use HostListener and HostBinding Class Decorators
+ ### 使用HostListener和HostBinding类装饰器
+ #### Style 06-03
+ #### 风格06-03
.s-rule.do
:marked
@@ -2414,11 +2367,10 @@ a(href="#toc") 回到顶部
## Services
## 服务
- ### Services are Singletons in Same Injector
- ### 在同一个注入器内,服务是单例
-
- #### Style 07-01
- #### 风格07-01
+ ### Services are Singletons in Same Injector
+ ### 在同一个注入器内,服务是单例
+ #### Style 07-01
+ #### 风格07-01
.s-rule.do
:marked
@@ -2447,11 +2399,10 @@ a(href="#toc") 回到顶部
.l-main-section
:marked
- ### Single Responsibility
- ### 单一职责
-
- #### Style 07-02
- #### 风格07-02
+ ### Single Responsibility
+ ### 单一职责
+ #### Style 07-02
+ #### 风格07-02
.s-rule.do
:marked
@@ -2483,11 +2434,10 @@ a(href="#toc") 回到顶部
.l-main-section
:marked
- ### Providing a Service
- ### 服务的提供
-
- #### Style 07-03
- #### 风格07-03
+ ### Providing a Service
+ ### 提供一个服务
+ #### Style 07-03
+ #### 风格07-03
.s-rule.do
:marked
@@ -2532,11 +2482,10 @@ a(href="#toc") 回到顶部
.l-main-section
:marked
- ### Use the @Injectable() Class Decorator
- ### 使用@Injectable()类装饰器
-
- #### Style 07-04
- #### 风格07-04
+ ### Use the @Injectable() Class Decorator
+ ### 使用@Injectable()类装饰器
+ #### Style 07-04
+ #### 风格07-04
.s-rule.do
:marked
@@ -2571,11 +2520,10 @@ a(href="#toc") 回到顶部
## Data Services
## 数据服务
- ### Separate Data Calls
- ### 分离数据调用
-
- #### Style 08-01
- #### 风格08-01
+ ### Separate Data Calls
+ ### 分离数据调用
+ #### Style 08-01
+ #### 风格08-01
.s-rule.do
:marked
@@ -2625,11 +2573,10 @@ a(href="#toc") Back to top
.l-main-section
:marked
- ### Implement Lifecycle Hooks Interfaces
- ### 实现生命周期钩子的接口
-
- #### Style 09-01
- #### 风格09-01
+ ### Implement Lifecycle Hooks Interfaces
+ ### 实现生命周期钩子接口
+ #### Style 09-01
+ #### 风格09-01
.s-rule.do
:marked
@@ -2667,11 +2614,10 @@ a(href="#toc") 回到顶部
.l-main-section
:marked
- ### Component Router
- ### 组件路由器
-
- #### Style 10-01
- #### 风格10-01
+ ### Component Router
+ ### 组件路由器
+ #### Style 10-01
+ #### 风格10-01
.s-rule.do
:marked
@@ -2731,11 +2677,10 @@ a(href="#toc") 回到顶部
.l-main-section
:marked
- ### Codelyzer
- ### Codelyzer
-
- #### Style A-01
- #### 风格A-01
+ ### Codelyzer
+ ### Codelyzer
+ #### Style A-01
+ #### 风格A-01
.s-rule.do
:marked
@@ -2755,11 +2700,10 @@ a(href="#toc") 回到顶部
.l-main-section
:marked
- ### File Templates and Snippets
- ### 文件模板和代码片段
-
- #### Style A-02
- #### 风格A-02
+ ### File Templates and Snippets
+ ### 文档模板和代码片段
+ #### Style A-02
+ #### 风格A-02
.s-rule.do
:marked
diff --git a/public/docs/ts/latest/tutorial/toh-pt1.jade b/public/docs/ts/latest/tutorial/toh-pt1.jade
index 8f2596a993..d656503f77 100644
--- a/public/docs/ts/latest/tutorial/toh-pt1.jade
+++ b/public/docs/ts/latest/tutorial/toh-pt1.jade
@@ -117,7 +117,7 @@ code-example(language="bash").
现在,有了一个`Hero`类,我们就要把组件`hero`属性的类型换成`Hero`了。
然后以`1`为id、以“Windstorm”为名字,初始化它。
-+makeExample('toh-1/ts-snippets/app.component.snippets.pt1.ts', 'hero-property-1', 'app.component.ts (hero属性)')(format=".")
++makeExample('toh-1/ts/app/app.component.ts', 'hero-property-1', 'app.component.ts (hero property)')(format=".")
:marked
Because we changed the hero from a string to an object,
diff --git a/public/docs/ts/latest/tutorial/toh-pt2.jade b/public/docs/ts/latest/tutorial/toh-pt2.jade
index dcd04c06d9..47beb4437b 100644
--- a/public/docs/ts/latest/tutorial/toh-pt2.jade
+++ b/public/docs/ts/latest/tutorial/toh-pt2.jade
@@ -71,7 +71,7 @@ code-example(language="bash").
我们先在`app.component.ts`的底部创建一个由十位英雄组成的数组。
-+makeExample('toh-2/ts/app/app.component.ts', 'hero-array', 'app.component.ts (英雄数组)')
++makeExample('toh-2/ts/app/app.component.ts', 'hero-array', 'app.component.ts (hero array)')
:marked
The `HEROES` array is of type `Hero`, the class defined in part one,
@@ -84,11 +84,11 @@ code-example(language="bash").
### Exposing heroes
### 导出英雄们
- Let’s create a property in `AppComponent` that exposes the heroes for binding.
+ Let’s create a public property in `AppComponent` that exposes the heroes for binding.
- 我们在`AppComponent`上创建一个属性,用来暴露这些英雄,以供绑定。
+ 我们在`AppComponent`上创建一个公开属性,用来暴露这些英雄,以供绑定。
-+makeExample('toh-2/ts-snippets/app.component.snippets.pt2.ts', 'hero-array-1', 'app.component.ts (英雄数组属性)')
++makeExample('toh-2/ts-snippets/app.component.snippets.pt2.ts', 'hero-array-1', 'app.component.ts (hero array property)')
:marked
We did not have to define the `heroes` type. TypeScript can infer it from the `HEROES` array.
@@ -113,7 +113,7 @@ code-example(language="bash").
我们的组件有了`heroes`属性,我们再到模板中创建一个无序列表来显示他们。
我们将在标题和英雄详情之间,插入下面这段HTML代码。
-+makeExample('toh-2/ts-snippets/app.component.snippets.pt2.ts', 'heroes-template-1', 'app.component.ts (英雄模板)')
++makeExample('toh-2/ts-snippets/app.component.snippets.pt2.ts', 'heroes-template-1', 'app.component.ts (heroes template)')
:marked
Now we have a template that we can fill with our heroes.
@@ -160,7 +160,7 @@ code-example(language="bash").
引号中赋值给`ngFor`的那段儿文本表示“*从`heroes`数组中取出每个英雄,存入一个局部的`hero`变量,并让它在相应的模板实例中可用*”。
- The `let` keyword before "hero" identifies the `hero` as a template input variable.
+ The `let` keyword before "hero" identifies `hero` as a template input variable.
We can reference this variable within the template to access a hero’s properties.
`hero`前的`let`关键字表示`hero`是一个模板输入变量。
@@ -199,13 +199,16 @@ code-example(language="bash").
要想给我们的组件添加一些样式,请把`@Component`装饰器的`styles`属性设置为下列CSS类:
-+makeExample('toh-2/ts/app/app.component.ts', 'styles-1', 'app.component.ts (添加样式)')
++makeExample('toh-2/ts/app/app.component.ts', 'styles', 'app.component.ts (styles)')(format=".")
:marked
Notice that we again use the back-tick notation for multi-line strings.
注意,我们又使用了反引号语法来书写多行字符串。
+ That's a lot of styles! We can put them inline as shown here, or we can move them out to their own file which will make it easier to code our component.
+ We'll do this in a later chapter. For now let's keep rolling.
+
When we assign styles to a component they are scoped to that specific component.
Our styles will only apply to our `AppComponent` and won't "leak" to the outer HTML.
@@ -216,14 +219,7 @@ code-example(language="bash").
用于显示英雄们的这个模板看起来像这样:
-+makeExample('toh-2/ts-snippets/app.component.snippets.pt2.ts', 'heroes-styled', 'app.component.ts (带样式的英雄们)')
-
-:marked
- That's a lot of styles! We can put them inline as shown here, or we can move them out to their own file which will make it easier to code our component.
- We'll do this in a later chapter. For now let's keep rolling.
-
- 样式有很多种写法!我们可以像这里一样内联在代码中,也可以把它们移出去,放到各自的文件中,以便给组件编码时更容易。
- 等到后面的章节中我们肯定会这么干,但现在,还是保持现在的节奏吧。
++makeExample('toh-2/ts-snippets/app.component.snippets.pt2.ts', 'heroes-styled', 'app.component.ts (styled heroes)')
.l-main-section
:marked
@@ -251,7 +247,7 @@ code-example(language="bash").
我们往`
`元素上插入一句Angular事件绑定代码,绑定到它的click事件。
- +makeExample('toh-2/ts-snippets/app.component.snippets.pt2.ts', 'selectedHero-click', 'app.component.ts (捕获click事件)')
+ +makeExample('toh-2/ts-snippets/app.component.snippets.pt2.ts', 'selectedHero-click', 'app.component.ts (template excerpt)')
:marked
Focus on the event binding
@@ -305,7 +301,7 @@ code-example(language="bash").
在`AppComponent`上,我们不再需要一个固定的`hero`属性。
那就直接把它改为`selectedHero`属性。
- +makeExample('toh-2/ts/app/app.component.ts', 'selected-hero-1', 'app.component.ts (selectedHero)')
+ +makeExample('toh-2/ts/app/app.component.ts', 'selected-hero', 'app.component.ts (selectedHero)')
:marked
We’ve decided that none of the heroes should be selected before the user picks a hero so
@@ -316,7 +312,8 @@ code-example(language="bash").
Now **add an `onSelect` method** that sets the `selectedHero` property to the `hero` the user clicked.
现在,**添加一个`onSelect`方法**,以便在用户点击一个英雄的时候,把它赋给`selectedHero`属性。
- +makeExample('toh-2/ts/app/app.component.ts', 'on-select-1', 'app.component.ts (onSelect)')
+
+ +makeExample('toh-2/ts/app/app.component.ts', 'on-select', 'app.component.ts (onSelect)')
:marked
We will be showing the selected hero's details in our template.
@@ -326,7 +323,7 @@ code-example(language="bash").
我们将把所选英雄的详细信息显示在模板中。目前,它仍然引用的是以前的`hero`属性。
我们这就修改模板,让它绑定到新的`selectedHero`属性上去。
- +makeExample('toh-2/ts-snippets/app.component.snippets.pt2.ts', 'selectedHero-details', 'app.component.ts (绑定到selectedHero的名字)')
+ +makeExample('toh-2/ts-snippets/app.component.snippets.pt2.ts', 'selectedHero-details', 'app.component.ts (template excerpt)')
:marked
### Hide the empty detail with ngIf
### 利用ngIf隐藏空的详情
@@ -428,19 +425,20 @@ code-example(language="bash").
关键是CSS类的名字:`selected`。当两位英雄一致时,它为`true`,否则为`false`。
也就是说:“*当两位英雄匹配时,应用上`selected`类,否则不应用*”。
- +makeExample('toh-2/ts-snippets/app.component.snippets.pt2.ts', 'class-selected-1', 'app.component.ts (设置CSS类)')(format=".")
+ +makeExample('toh-2/ts-snippets/app.component.snippets.pt2.ts', 'class-selected-1', 'app.component.ts (setting the CSS class)')(format=".")
:marked
Notice in the template that the `class.selected` is surrounded in square brackets (`[]`).
- This is the syntax for a Property Binding, a binding in which data flows one way
+ This is the syntax for a **property binding**, a binding in which data flows one way
from the data source (the expression `hero === selectedHero`) to a property of `class`.
注意,模板中的`class.selected`是括在一对方括号中的。
这就是“属性绑定”的语法,一种从数据源(即`hero === selectedHero`表达式)到`class`属性的单向数据流。
- +makeExample('toh-2/ts-snippets/app.component.snippets.pt2.ts', 'class-selected-2', 'app.component.ts (Styling each hero)')(format=".")
+
+ +makeExample('toh-2/ts-snippets/app.component.snippets.pt2.ts', 'class-selected-2', 'app.component.ts (styling each hero)')(format=".")
.l-sub-section
:marked
- Learn more about [Property Binding](../guide/template-syntax.html#property-binding)
+ Learn more about [property bindings](../guide/template-syntax.html#property-binding)
in the Template Syntax chapter.
学习关于[属性绑定](../guide/template-syntax.html#property-binding)
@@ -464,7 +462,7 @@ code-example(language="bash").
完整的`app.component.ts`文件如下:
- +makeExample('toh-2/ts/app/app.component.ts', 'pt2', 'app.component.ts')
+ +makeExample('toh-2/ts/app/app.component.ts', '', 'app.component.ts')
.l-main-section
:marked
diff --git a/public/docs/ts/latest/tutorial/toh-pt3.jade b/public/docs/ts/latest/tutorial/toh-pt3.jade
index 0f57038c27..0cba44a573 100644
--- a/public/docs/ts/latest/tutorial/toh-pt3.jade
+++ b/public/docs/ts/latest/tutorial/toh-pt3.jade
@@ -41,7 +41,7 @@ p 运行这部分的#[+liveExampleLink2('在线例子', 'toh-3')]。
我们要启动TypeScript编译器,它会监视文件变更,并启动开发服务器。只要敲:
-code-example(format="." language="bash").
+code-example(language="bash").
npm start
:marked
@@ -82,7 +82,7 @@ code-example(format="." language="bash").
在`app`目录下添加一个名叫`hero-detail.component.ts`的文件,并且创建`HeroDetailComponent`。代码如下:
-+makeExample('toh-3/ts/app/hero-detail.component.ts', 'v1', 'hero-detail.component.ts (初始版本)')(format=".")
++makeExample('toh-3/ts/app/hero-detail.component.ts', 'v1', 'app/hero-detail.component.ts (initial version)')(format=".")
.l-sub-section
:marked
### Naming conventions
@@ -100,10 +100,11 @@ code-example(format="." language="bash").
我们的所有组件名都以`Component`结尾。所有组件的文件名都以`.component`结尾。
- We spell our file names in lower dash case (AKA "kebab-case") so we don't worry about
+ We spell our file names in lower **[dash case](../guide/glossary.html#!#dash-case)**
+ (AKA **[kebab-case](../guide/glossary.html#!#kebab-case)**) so we don't worry about
case sensitivity on the server or in source control.
- 这里我们使用小写中线命名法(也叫烤串命名法)拼写文件名,所以不用担心它在服务器或者版本控制系统中出现大小写问题。
+ 这里我们使用小写**[中线命名法](../guide/glossary.html#!#dash-case)**(也叫**[烤串命名法](../guide/glossary.html#!#kebab-case)**)拼写文件名,所以不用担心它在服务器或者版本控制系统中出现大小写问题。