2016-02-06 02:27:06 -05:00
|
|
|
|
include ../_util-fns
|
2015-10-15 03:51:24 -04:00
|
|
|
|
|
docs(tutorial): combines all 4 sections + revisions/updates to a.53, hides 3&4
closes #488
ToH History (oldest-to-latest):
----------------------------
created code example/snippets files for use with +makeExample, replace usage of "pre.prettyprint.lang-bash" with this: code-example(format="." language="bash").
fixed spelling errors in examples file path used by +makeExample
changed usage of "code-example" to "+makeExample"
adding code example/snippets files used in toh 1
fixed example file paths, replaced "pre.prettyprint.lang-bash" with "code-example. "
(docs) toh-pt3 initial state
created code examples for display in jade, starting conversion of Google doc and trying +makeExample rendering
all text copied from doc to jade, still some styling and formatting to perform
completed conversion and styling, moved toh3 example files to "tutorial" folder under _examples
created specific code example files for chapter toh 3 and re-pathed references in +makeExample
minor edit
docs) toh combined - initial combined commit
updated ToH for a.52
tons of changes, including de-kebab-ing, removed src folder, updated tsconfig too
fixing snippets using incorrect ending input tag
using inline html and css for the app.component.
ToH Part 1 Code: updated the imports, removed obsolete directive delcarations
ToH Code Part 1: updated to use imports, interface. will hit others soon
toh part 1: ngModel fix
toh part1: removed obsolete story that referred to how we used to have to import and declare all directives we used. yay!
ToH Part 1: updated to use `boot.ts` and `app.component.ts`. this affected the partials, snippets, and the story.
toh part 1: using `npm run go`
toh parts 1 -4: modified all places to use `npm run go`
toh part 1: refactor for jade
toh part 1: fixing the code samples
toh part 2: seeping through the story
toh part 2: fixing snippets.
toh part 2: replaced ngClass with class.selected
toh part 2: removed whitespace
toh part 2: added final state to the code
toh: fixing paths
toh part 4: fixing src/app path to app
toh part 3: fixing folder path
toh part 2: fixed typo
toh part 2: typo on ngModel
toh part 2: added ngif
toh part 2: removed old hero property. moved the details lower, where we need it
toh index: updated hero list image to show consistent styling as the other images here
QS spelling error (targes -> targets)
tweeks: space and ngIF
2015-11-15 21:04:43 -05:00
|
|
|
|
:marked
|
|
|
|
|
# Once Upon a Time
|
2016-04-12 07:07:06 -04:00
|
|
|
|
# 很久很久以前
|
2015-10-15 03:51:24 -04:00
|
|
|
|
|
docs(tutorial): combines all 4 sections + revisions/updates to a.53, hides 3&4
closes #488
ToH History (oldest-to-latest):
----------------------------
created code example/snippets files for use with +makeExample, replace usage of "pre.prettyprint.lang-bash" with this: code-example(format="." language="bash").
fixed spelling errors in examples file path used by +makeExample
changed usage of "code-example" to "+makeExample"
adding code example/snippets files used in toh 1
fixed example file paths, replaced "pre.prettyprint.lang-bash" with "code-example. "
(docs) toh-pt3 initial state
created code examples for display in jade, starting conversion of Google doc and trying +makeExample rendering
all text copied from doc to jade, still some styling and formatting to perform
completed conversion and styling, moved toh3 example files to "tutorial" folder under _examples
created specific code example files for chapter toh 3 and re-pathed references in +makeExample
minor edit
docs) toh combined - initial combined commit
updated ToH for a.52
tons of changes, including de-kebab-ing, removed src folder, updated tsconfig too
fixing snippets using incorrect ending input tag
using inline html and css for the app.component.
ToH Part 1 Code: updated the imports, removed obsolete directive delcarations
ToH Code Part 1: updated to use imports, interface. will hit others soon
toh part 1: ngModel fix
toh part1: removed obsolete story that referred to how we used to have to import and declare all directives we used. yay!
ToH Part 1: updated to use `boot.ts` and `app.component.ts`. this affected the partials, snippets, and the story.
toh part 1: using `npm run go`
toh parts 1 -4: modified all places to use `npm run go`
toh part 1: refactor for jade
toh part 1: fixing the code samples
toh part 2: seeping through the story
toh part 2: fixing snippets.
toh part 2: replaced ngClass with class.selected
toh part 2: removed whitespace
toh part 2: added final state to the code
toh: fixing paths
toh part 4: fixing src/app path to app
toh part 3: fixing folder path
toh part 2: fixed typo
toh part 2: typo on ngModel
toh part 2: added ngif
toh part 2: removed old hero property. moved the details lower, where we need it
toh index: updated hero list image to show consistent styling as the other images here
QS spelling error (targes -> targets)
tweeks: space and ngIF
2015-11-15 21:04:43 -05:00
|
|
|
|
Every story starts somewhere. Our story starts where the [QuickStart](../quickstart.html) ends.
|
2016-04-12 07:07:06 -04:00
|
|
|
|
|
|
|
|
|
每个故事,都有一个起点。而我们的故事则开始于[QuickStart](../quickstart.html)的结尾处。
|
2015-10-15 03:51:24 -04:00
|
|
|
|
|
2015-12-14 23:05:13 -05:00
|
|
|
|
[Run the live example for part 1](/resources/live-examples/toh-1/ts/plnkr.html)
|
2016-04-12 07:07:06 -04:00
|
|
|
|
|
|
|
|
|
[运行第一部分的鲜活范例](/resources/live-examples/toh-1/ts/plnkr.html)
|
2015-12-14 23:05:13 -05:00
|
|
|
|
|
2016-03-13 15:50:50 -04:00
|
|
|
|
Create a folder called `angular2-tour-of-heroes` and follow the [QuickStart](../quickstart.html) steps
|
|
|
|
|
which provide the prerequisites, the folder structure, and the core files for our Tour of Heroes.
|
2015-10-15 03:51:24 -04:00
|
|
|
|
|
2016-04-17 11:31:22 -04:00
|
|
|
|
创建一个名为`angular2-tour-of-heroes`的文件夹,并且遵循[QuickStart](../quickstart.html)中的步骤初始化它 —— 环境准备、目录结构,以及我们《英雄指南》的核心文件。
|
2016-04-12 07:07:06 -04:00
|
|
|
|
|
2016-03-13 15:50:50 -04:00
|
|
|
|
include ../_quickstart_repo
|
|
|
|
|
:marked
|
|
|
|
|
We should have the following structure:
|
2016-04-12 07:07:06 -04:00
|
|
|
|
|
|
|
|
|
我们应该有如下目录结构:
|
2015-10-15 03:51:24 -04:00
|
|
|
|
|
2015-12-14 23:05:13 -05:00
|
|
|
|
.filetree
|
|
|
|
|
.file angular2-tour-of-heroes
|
|
|
|
|
.children
|
|
|
|
|
.file app
|
|
|
|
|
.children
|
|
|
|
|
.file app.component.ts
|
2016-01-28 19:15:26 -05:00
|
|
|
|
.file main.ts
|
2016-02-11 18:08:06 -05:00
|
|
|
|
.file node_modules ...
|
|
|
|
|
.file typings ...
|
2015-12-14 23:05:13 -05:00
|
|
|
|
.file index.html
|
|
|
|
|
.file package.json
|
2016-03-13 15:50:50 -04:00
|
|
|
|
.file styles.css
|
2016-04-27 14:28:22 -04:00
|
|
|
|
.file systemjs.config.js
|
2015-12-14 23:05:13 -05:00
|
|
|
|
.file tsconfig.json
|
2016-02-11 18:08:06 -05:00
|
|
|
|
.file typings.json
|
docs(tutorial): combines all 4 sections + revisions/updates to a.53, hides 3&4
closes #488
ToH History (oldest-to-latest):
----------------------------
created code example/snippets files for use with +makeExample, replace usage of "pre.prettyprint.lang-bash" with this: code-example(format="." language="bash").
fixed spelling errors in examples file path used by +makeExample
changed usage of "code-example" to "+makeExample"
adding code example/snippets files used in toh 1
fixed example file paths, replaced "pre.prettyprint.lang-bash" with "code-example. "
(docs) toh-pt3 initial state
created code examples for display in jade, starting conversion of Google doc and trying +makeExample rendering
all text copied from doc to jade, still some styling and formatting to perform
completed conversion and styling, moved toh3 example files to "tutorial" folder under _examples
created specific code example files for chapter toh 3 and re-pathed references in +makeExample
minor edit
docs) toh combined - initial combined commit
updated ToH for a.52
tons of changes, including de-kebab-ing, removed src folder, updated tsconfig too
fixing snippets using incorrect ending input tag
using inline html and css for the app.component.
ToH Part 1 Code: updated the imports, removed obsolete directive delcarations
ToH Code Part 1: updated to use imports, interface. will hit others soon
toh part 1: ngModel fix
toh part1: removed obsolete story that referred to how we used to have to import and declare all directives we used. yay!
ToH Part 1: updated to use `boot.ts` and `app.component.ts`. this affected the partials, snippets, and the story.
toh part 1: using `npm run go`
toh parts 1 -4: modified all places to use `npm run go`
toh part 1: refactor for jade
toh part 1: fixing the code samples
toh part 2: seeping through the story
toh part 2: fixing snippets.
toh part 2: replaced ngClass with class.selected
toh part 2: removed whitespace
toh part 2: added final state to the code
toh: fixing paths
toh part 4: fixing src/app path to app
toh part 3: fixing folder path
toh part 2: fixed typo
toh part 2: typo on ngModel
toh part 2: added ngif
toh part 2: removed old hero property. moved the details lower, where we need it
toh index: updated hero list image to show consistent styling as the other images here
QS spelling error (targes -> targets)
tweeks: space and ngIF
2015-11-15 21:04:43 -05:00
|
|
|
|
:marked
|
|
|
|
|
## Keep the app transpiling and running
|
2016-04-12 07:07:06 -04:00
|
|
|
|
## 保持应用不断转译和运行
|
docs(tutorial): combines all 4 sections + revisions/updates to a.53, hides 3&4
closes #488
ToH History (oldest-to-latest):
----------------------------
created code example/snippets files for use with +makeExample, replace usage of "pre.prettyprint.lang-bash" with this: code-example(format="." language="bash").
fixed spelling errors in examples file path used by +makeExample
changed usage of "code-example" to "+makeExample"
adding code example/snippets files used in toh 1
fixed example file paths, replaced "pre.prettyprint.lang-bash" with "code-example. "
(docs) toh-pt3 initial state
created code examples for display in jade, starting conversion of Google doc and trying +makeExample rendering
all text copied from doc to jade, still some styling and formatting to perform
completed conversion and styling, moved toh3 example files to "tutorial" folder under _examples
created specific code example files for chapter toh 3 and re-pathed references in +makeExample
minor edit
docs) toh combined - initial combined commit
updated ToH for a.52
tons of changes, including de-kebab-ing, removed src folder, updated tsconfig too
fixing snippets using incorrect ending input tag
using inline html and css for the app.component.
ToH Part 1 Code: updated the imports, removed obsolete directive delcarations
ToH Code Part 1: updated to use imports, interface. will hit others soon
toh part 1: ngModel fix
toh part1: removed obsolete story that referred to how we used to have to import and declare all directives we used. yay!
ToH Part 1: updated to use `boot.ts` and `app.component.ts`. this affected the partials, snippets, and the story.
toh part 1: using `npm run go`
toh parts 1 -4: modified all places to use `npm run go`
toh part 1: refactor for jade
toh part 1: fixing the code samples
toh part 2: seeping through the story
toh part 2: fixing snippets.
toh part 2: replaced ngClass with class.selected
toh part 2: removed whitespace
toh part 2: added final state to the code
toh: fixing paths
toh part 4: fixing src/app path to app
toh part 3: fixing folder path
toh part 2: fixed typo
toh part 2: typo on ngModel
toh part 2: added ngif
toh part 2: removed old hero property. moved the details lower, where we need it
toh index: updated hero list image to show consistent styling as the other images here
QS spelling error (targes -> targets)
tweeks: space and ngIF
2015-11-15 21:04:43 -05:00
|
|
|
|
We want to start the TypeScript compiler, have it watch for changes, and start our server. We'll do this by typing
|
2016-04-12 07:07:06 -04:00
|
|
|
|
|
|
|
|
|
我们要启动TypeScript编译器,它会监视文件变更,并且启动开发服务器。我们只要敲:
|
2015-10-15 03:51:24 -04:00
|
|
|
|
|
docs(tutorial): combines all 4 sections + revisions/updates to a.53, hides 3&4
closes #488
ToH History (oldest-to-latest):
----------------------------
created code example/snippets files for use with +makeExample, replace usage of "pre.prettyprint.lang-bash" with this: code-example(format="." language="bash").
fixed spelling errors in examples file path used by +makeExample
changed usage of "code-example" to "+makeExample"
adding code example/snippets files used in toh 1
fixed example file paths, replaced "pre.prettyprint.lang-bash" with "code-example. "
(docs) toh-pt3 initial state
created code examples for display in jade, starting conversion of Google doc and trying +makeExample rendering
all text copied from doc to jade, still some styling and formatting to perform
completed conversion and styling, moved toh3 example files to "tutorial" folder under _examples
created specific code example files for chapter toh 3 and re-pathed references in +makeExample
minor edit
docs) toh combined - initial combined commit
updated ToH for a.52
tons of changes, including de-kebab-ing, removed src folder, updated tsconfig too
fixing snippets using incorrect ending input tag
using inline html and css for the app.component.
ToH Part 1 Code: updated the imports, removed obsolete directive delcarations
ToH Code Part 1: updated to use imports, interface. will hit others soon
toh part 1: ngModel fix
toh part1: removed obsolete story that referred to how we used to have to import and declare all directives we used. yay!
ToH Part 1: updated to use `boot.ts` and `app.component.ts`. this affected the partials, snippets, and the story.
toh part 1: using `npm run go`
toh parts 1 -4: modified all places to use `npm run go`
toh part 1: refactor for jade
toh part 1: fixing the code samples
toh part 2: seeping through the story
toh part 2: fixing snippets.
toh part 2: replaced ngClass with class.selected
toh part 2: removed whitespace
toh part 2: added final state to the code
toh: fixing paths
toh part 4: fixing src/app path to app
toh part 3: fixing folder path
toh part 2: fixed typo
toh part 2: typo on ngModel
toh part 2: added ngif
toh part 2: removed old hero property. moved the details lower, where we need it
toh index: updated hero list image to show consistent styling as the other images here
QS spelling error (targes -> targets)
tweeks: space and ngIF
2015-11-15 21:04:43 -05:00
|
|
|
|
code-example(format="" language="bash").
|
2015-12-16 11:16:16 -05:00
|
|
|
|
npm start
|
2015-10-15 03:51:24 -04:00
|
|
|
|
|
docs(tutorial): combines all 4 sections + revisions/updates to a.53, hides 3&4
closes #488
ToH History (oldest-to-latest):
----------------------------
created code example/snippets files for use with +makeExample, replace usage of "pre.prettyprint.lang-bash" with this: code-example(format="." language="bash").
fixed spelling errors in examples file path used by +makeExample
changed usage of "code-example" to "+makeExample"
adding code example/snippets files used in toh 1
fixed example file paths, replaced "pre.prettyprint.lang-bash" with "code-example. "
(docs) toh-pt3 initial state
created code examples for display in jade, starting conversion of Google doc and trying +makeExample rendering
all text copied from doc to jade, still some styling and formatting to perform
completed conversion and styling, moved toh3 example files to "tutorial" folder under _examples
created specific code example files for chapter toh 3 and re-pathed references in +makeExample
minor edit
docs) toh combined - initial combined commit
updated ToH for a.52
tons of changes, including de-kebab-ing, removed src folder, updated tsconfig too
fixing snippets using incorrect ending input tag
using inline html and css for the app.component.
ToH Part 1 Code: updated the imports, removed obsolete directive delcarations
ToH Code Part 1: updated to use imports, interface. will hit others soon
toh part 1: ngModel fix
toh part1: removed obsolete story that referred to how we used to have to import and declare all directives we used. yay!
ToH Part 1: updated to use `boot.ts` and `app.component.ts`. this affected the partials, snippets, and the story.
toh part 1: using `npm run go`
toh parts 1 -4: modified all places to use `npm run go`
toh part 1: refactor for jade
toh part 1: fixing the code samples
toh part 2: seeping through the story
toh part 2: fixing snippets.
toh part 2: replaced ngClass with class.selected
toh part 2: removed whitespace
toh part 2: added final state to the code
toh: fixing paths
toh part 4: fixing src/app path to app
toh part 3: fixing folder path
toh part 2: fixed typo
toh part 2: typo on ngModel
toh part 2: added ngif
toh part 2: removed old hero property. moved the details lower, where we need it
toh index: updated hero list image to show consistent styling as the other images here
QS spelling error (targes -> targets)
tweeks: space and ngIF
2015-11-15 21:04:43 -05:00
|
|
|
|
:marked
|
2015-12-14 23:05:13 -05:00
|
|
|
|
This command runs the compiler in watch mode, starts the server, launches the app in a browser,
|
docs(tutorial): combines all 4 sections + revisions/updates to a.53, hides 3&4
closes #488
ToH History (oldest-to-latest):
----------------------------
created code example/snippets files for use with +makeExample, replace usage of "pre.prettyprint.lang-bash" with this: code-example(format="." language="bash").
fixed spelling errors in examples file path used by +makeExample
changed usage of "code-example" to "+makeExample"
adding code example/snippets files used in toh 1
fixed example file paths, replaced "pre.prettyprint.lang-bash" with "code-example. "
(docs) toh-pt3 initial state
created code examples for display in jade, starting conversion of Google doc and trying +makeExample rendering
all text copied from doc to jade, still some styling and formatting to perform
completed conversion and styling, moved toh3 example files to "tutorial" folder under _examples
created specific code example files for chapter toh 3 and re-pathed references in +makeExample
minor edit
docs) toh combined - initial combined commit
updated ToH for a.52
tons of changes, including de-kebab-ing, removed src folder, updated tsconfig too
fixing snippets using incorrect ending input tag
using inline html and css for the app.component.
ToH Part 1 Code: updated the imports, removed obsolete directive delcarations
ToH Code Part 1: updated to use imports, interface. will hit others soon
toh part 1: ngModel fix
toh part1: removed obsolete story that referred to how we used to have to import and declare all directives we used. yay!
ToH Part 1: updated to use `boot.ts` and `app.component.ts`. this affected the partials, snippets, and the story.
toh part 1: using `npm run go`
toh parts 1 -4: modified all places to use `npm run go`
toh part 1: refactor for jade
toh part 1: fixing the code samples
toh part 2: seeping through the story
toh part 2: fixing snippets.
toh part 2: replaced ngClass with class.selected
toh part 2: removed whitespace
toh part 2: added final state to the code
toh: fixing paths
toh part 4: fixing src/app path to app
toh part 3: fixing folder path
toh part 2: fixed typo
toh part 2: typo on ngModel
toh part 2: added ngif
toh part 2: removed old hero property. moved the details lower, where we need it
toh index: updated hero list image to show consistent styling as the other images here
QS spelling error (targes -> targets)
tweeks: space and ngIF
2015-11-15 21:04:43 -05:00
|
|
|
|
and keeps the app running while we continue to build the Tour of Heroes.
|
2015-10-15 03:51:24 -04:00
|
|
|
|
|
2016-04-17 11:31:22 -04:00
|
|
|
|
这个命令会在监视模式下运行编译器,启动开发服务器,在浏览器中启动我们的应用,并且在我们构建《英雄指南》的时候让应用得以持续运行。
|
2016-04-12 07:07:06 -04:00
|
|
|
|
|
2015-10-15 03:51:24 -04:00
|
|
|
|
.l-main-section
|
2015-11-10 13:31:46 -05:00
|
|
|
|
:marked
|
2015-10-16 04:06:56 -04:00
|
|
|
|
## Show our Hero
|
2016-04-14 09:45:12 -04:00
|
|
|
|
## 显示我们的英雄
|
2015-10-15 03:51:24 -04:00
|
|
|
|
We want to display Hero data in our app
|
2016-04-12 07:07:06 -04:00
|
|
|
|
|
|
|
|
|
我们要在我们的应用中显示英雄数据
|
2015-10-15 03:51:24 -04:00
|
|
|
|
|
|
|
|
|
Let's add two properties to our `AppComponent`, a `title` property for the application name and a `hero` property
|
|
|
|
|
for a hero named "Windstorm".
|
2016-04-12 07:07:06 -04:00
|
|
|
|
|
|
|
|
|
让我们给`AppComponent`添加两个属性:`title`属性表示应用的名字,而`hero`属性表示一个名叫“Windstorm”的英雄。
|
2015-10-15 03:51:24 -04:00
|
|
|
|
|
2016-04-12 07:07:06 -04:00
|
|
|
|
+makeExample('toh-1/ts-snippets/app.component.snippets.pt1.ts', 'app-component-1', 'app.component.ts (AppComponent类)')(format=".")
|
2015-10-15 03:51:24 -04:00
|
|
|
|
|
2015-11-10 13:31:46 -05:00
|
|
|
|
:marked
|
2015-10-15 03:51:24 -04:00
|
|
|
|
Now we update the template in the `@Component` decoration with data bindings to these new properties.
|
2016-04-12 07:07:06 -04:00
|
|
|
|
|
|
|
|
|
现在,我们为这些新属性建立数据绑定,以更新`@Component`装饰器中指定的模板
|
2015-10-15 03:51:24 -04:00
|
|
|
|
|
2015-12-14 23:05:13 -05:00
|
|
|
|
+makeExample('toh-1/ts-snippets/app.component.snippets.pt1.ts', 'show-hero')
|
|
|
|
|
|
2015-11-10 13:31:46 -05:00
|
|
|
|
:marked
|
2015-10-15 03:51:24 -04:00
|
|
|
|
The browser should refresh and display our title and hero.
|
2016-04-12 07:07:06 -04:00
|
|
|
|
|
|
|
|
|
保存后,浏览器应该会自动刷新,并显示我们的标题和英雄。
|
2015-10-15 03:51:24 -04:00
|
|
|
|
|
|
|
|
|
The double curly braces tell our app to read the `title` and `hero` properties from the component and render them.
|
2015-11-14 03:22:26 -05:00
|
|
|
|
This is the "interpolation" form of one-way data binding.
|
2016-04-12 07:07:06 -04:00
|
|
|
|
|
|
|
|
|
这里的“双大括号”会告诉应用:从组件中读取`title`和`hero`属性,并且渲染它们。这就是单向数据绑定的“插值表达式”格式。
|
|
|
|
|
|
docs(tutorial): combines all 4 sections + revisions/updates to a.53, hides 3&4
closes #488
ToH History (oldest-to-latest):
----------------------------
created code example/snippets files for use with +makeExample, replace usage of "pre.prettyprint.lang-bash" with this: code-example(format="." language="bash").
fixed spelling errors in examples file path used by +makeExample
changed usage of "code-example" to "+makeExample"
adding code example/snippets files used in toh 1
fixed example file paths, replaced "pre.prettyprint.lang-bash" with "code-example. "
(docs) toh-pt3 initial state
created code examples for display in jade, starting conversion of Google doc and trying +makeExample rendering
all text copied from doc to jade, still some styling and formatting to perform
completed conversion and styling, moved toh3 example files to "tutorial" folder under _examples
created specific code example files for chapter toh 3 and re-pathed references in +makeExample
minor edit
docs) toh combined - initial combined commit
updated ToH for a.52
tons of changes, including de-kebab-ing, removed src folder, updated tsconfig too
fixing snippets using incorrect ending input tag
using inline html and css for the app.component.
ToH Part 1 Code: updated the imports, removed obsolete directive delcarations
ToH Code Part 1: updated to use imports, interface. will hit others soon
toh part 1: ngModel fix
toh part1: removed obsolete story that referred to how we used to have to import and declare all directives we used. yay!
ToH Part 1: updated to use `boot.ts` and `app.component.ts`. this affected the partials, snippets, and the story.
toh part 1: using `npm run go`
toh parts 1 -4: modified all places to use `npm run go`
toh part 1: refactor for jade
toh part 1: fixing the code samples
toh part 2: seeping through the story
toh part 2: fixing snippets.
toh part 2: replaced ngClass with class.selected
toh part 2: removed whitespace
toh part 2: added final state to the code
toh: fixing paths
toh part 4: fixing src/app path to app
toh part 3: fixing folder path
toh part 2: fixed typo
toh part 2: typo on ngModel
toh part 2: added ngif
toh part 2: removed old hero property. moved the details lower, where we need it
toh index: updated hero list image to show consistent styling as the other images here
QS spelling error (targes -> targets)
tweeks: space and ngIF
2015-11-15 21:04:43 -05:00
|
|
|
|
.l-sub-section
|
2015-11-14 03:22:26 -05:00
|
|
|
|
:marked
|
docs(tutorial): combines all 4 sections + revisions/updates to a.53, hides 3&4
closes #488
ToH History (oldest-to-latest):
----------------------------
created code example/snippets files for use with +makeExample, replace usage of "pre.prettyprint.lang-bash" with this: code-example(format="." language="bash").
fixed spelling errors in examples file path used by +makeExample
changed usage of "code-example" to "+makeExample"
adding code example/snippets files used in toh 1
fixed example file paths, replaced "pre.prettyprint.lang-bash" with "code-example. "
(docs) toh-pt3 initial state
created code examples for display in jade, starting conversion of Google doc and trying +makeExample rendering
all text copied from doc to jade, still some styling and formatting to perform
completed conversion and styling, moved toh3 example files to "tutorial" folder under _examples
created specific code example files for chapter toh 3 and re-pathed references in +makeExample
minor edit
docs) toh combined - initial combined commit
updated ToH for a.52
tons of changes, including de-kebab-ing, removed src folder, updated tsconfig too
fixing snippets using incorrect ending input tag
using inline html and css for the app.component.
ToH Part 1 Code: updated the imports, removed obsolete directive delcarations
ToH Code Part 1: updated to use imports, interface. will hit others soon
toh part 1: ngModel fix
toh part1: removed obsolete story that referred to how we used to have to import and declare all directives we used. yay!
ToH Part 1: updated to use `boot.ts` and `app.component.ts`. this affected the partials, snippets, and the story.
toh part 1: using `npm run go`
toh parts 1 -4: modified all places to use `npm run go`
toh part 1: refactor for jade
toh part 1: fixing the code samples
toh part 2: seeping through the story
toh part 2: fixing snippets.
toh part 2: replaced ngClass with class.selected
toh part 2: removed whitespace
toh part 2: added final state to the code
toh: fixing paths
toh part 4: fixing src/app path to app
toh part 3: fixing folder path
toh part 2: fixed typo
toh part 2: typo on ngModel
toh part 2: added ngif
toh part 2: removed old hero property. moved the details lower, where we need it
toh index: updated hero list image to show consistent styling as the other images here
QS spelling error (targes -> targets)
tweeks: space and ngIF
2015-11-15 21:04:43 -05:00
|
|
|
|
Learn more about interpolation in the [Displaying Data chapter](../guide/displaying-data.html).
|
2016-04-12 07:07:06 -04:00
|
|
|
|
|
2016-04-14 09:45:12 -04:00
|
|
|
|
想了解插值表达式的更多知识,参阅[“显示数据”一章](../guide/displaying-data.html)。
|
docs(tutorial): combines all 4 sections + revisions/updates to a.53, hides 3&4
closes #488
ToH History (oldest-to-latest):
----------------------------
created code example/snippets files for use with +makeExample, replace usage of "pre.prettyprint.lang-bash" with this: code-example(format="." language="bash").
fixed spelling errors in examples file path used by +makeExample
changed usage of "code-example" to "+makeExample"
adding code example/snippets files used in toh 1
fixed example file paths, replaced "pre.prettyprint.lang-bash" with "code-example. "
(docs) toh-pt3 initial state
created code examples for display in jade, starting conversion of Google doc and trying +makeExample rendering
all text copied from doc to jade, still some styling and formatting to perform
completed conversion and styling, moved toh3 example files to "tutorial" folder under _examples
created specific code example files for chapter toh 3 and re-pathed references in +makeExample
minor edit
docs) toh combined - initial combined commit
updated ToH for a.52
tons of changes, including de-kebab-ing, removed src folder, updated tsconfig too
fixing snippets using incorrect ending input tag
using inline html and css for the app.component.
ToH Part 1 Code: updated the imports, removed obsolete directive delcarations
ToH Code Part 1: updated to use imports, interface. will hit others soon
toh part 1: ngModel fix
toh part1: removed obsolete story that referred to how we used to have to import and declare all directives we used. yay!
ToH Part 1: updated to use `boot.ts` and `app.component.ts`. this affected the partials, snippets, and the story.
toh part 1: using `npm run go`
toh parts 1 -4: modified all places to use `npm run go`
toh part 1: refactor for jade
toh part 1: fixing the code samples
toh part 2: seeping through the story
toh part 2: fixing snippets.
toh part 2: replaced ngClass with class.selected
toh part 2: removed whitespace
toh part 2: added final state to the code
toh: fixing paths
toh part 4: fixing src/app path to app
toh part 3: fixing folder path
toh part 2: fixed typo
toh part 2: typo on ngModel
toh part 2: added ngif
toh part 2: removed old hero property. moved the details lower, where we need it
toh index: updated hero list image to show consistent styling as the other images here
QS spelling error (targes -> targets)
tweeks: space and ngIF
2015-11-15 21:04:43 -05:00
|
|
|
|
:marked
|
|
|
|
|
### Hero object
|
2016-04-12 07:07:06 -04:00
|
|
|
|
### Hero对象
|
2015-10-15 03:51:24 -04:00
|
|
|
|
|
docs(tutorial): combines all 4 sections + revisions/updates to a.53, hides 3&4
closes #488
ToH History (oldest-to-latest):
----------------------------
created code example/snippets files for use with +makeExample, replace usage of "pre.prettyprint.lang-bash" with this: code-example(format="." language="bash").
fixed spelling errors in examples file path used by +makeExample
changed usage of "code-example" to "+makeExample"
adding code example/snippets files used in toh 1
fixed example file paths, replaced "pre.prettyprint.lang-bash" with "code-example. "
(docs) toh-pt3 initial state
created code examples for display in jade, starting conversion of Google doc and trying +makeExample rendering
all text copied from doc to jade, still some styling and formatting to perform
completed conversion and styling, moved toh3 example files to "tutorial" folder under _examples
created specific code example files for chapter toh 3 and re-pathed references in +makeExample
minor edit
docs) toh combined - initial combined commit
updated ToH for a.52
tons of changes, including de-kebab-ing, removed src folder, updated tsconfig too
fixing snippets using incorrect ending input tag
using inline html and css for the app.component.
ToH Part 1 Code: updated the imports, removed obsolete directive delcarations
ToH Code Part 1: updated to use imports, interface. will hit others soon
toh part 1: ngModel fix
toh part1: removed obsolete story that referred to how we used to have to import and declare all directives we used. yay!
ToH Part 1: updated to use `boot.ts` and `app.component.ts`. this affected the partials, snippets, and the story.
toh part 1: using `npm run go`
toh parts 1 -4: modified all places to use `npm run go`
toh part 1: refactor for jade
toh part 1: fixing the code samples
toh part 2: seeping through the story
toh part 2: fixing snippets.
toh part 2: replaced ngClass with class.selected
toh part 2: removed whitespace
toh part 2: added final state to the code
toh: fixing paths
toh part 4: fixing src/app path to app
toh part 3: fixing folder path
toh part 2: fixed typo
toh part 2: typo on ngModel
toh part 2: added ngif
toh part 2: removed old hero property. moved the details lower, where we need it
toh index: updated hero list image to show consistent styling as the other images here
QS spelling error (targes -> targets)
tweeks: space and ngIF
2015-11-15 21:04:43 -05:00
|
|
|
|
At the moment, our hero is just a name. Our hero needs more properties.
|
2016-03-24 08:31:27 -04:00
|
|
|
|
Let's convert the `hero` from a literal string to a class.
|
2015-10-15 03:51:24 -04:00
|
|
|
|
|
2016-04-12 07:07:06 -04:00
|
|
|
|
此时此刻,我们的英雄还只有一个名字。显然,我们的英雄应该有更多的属性。
|
|
|
|
|
让我们把`hero`从一个字符串字面量换成一个类。
|
|
|
|
|
|
2016-03-24 08:31:27 -04:00
|
|
|
|
Create a `Hero` class with `id` and `name` properties.
|
2016-03-09 00:00:09 -05:00
|
|
|
|
For now put this near the top of the `app.component.ts` file, just below the import statement.
|
2015-10-15 03:51:24 -04:00
|
|
|
|
|
2016-04-12 07:07:06 -04:00
|
|
|
|
创建一个`Hero`类,它具有`id`和`name`属性。
|
|
|
|
|
现在,把下列代码放在`app.component.ts`的顶部,仅次于import语句。
|
|
|
|
|
|
2016-03-24 08:31:27 -04:00
|
|
|
|
+makeExample('toh-1/ts/app/app.component.ts', 'hero-class-1', 'app.component.ts (Hero class)')(format=".")
|
2015-10-15 03:51:24 -04:00
|
|
|
|
|
docs(tutorial): combines all 4 sections + revisions/updates to a.53, hides 3&4
closes #488
ToH History (oldest-to-latest):
----------------------------
created code example/snippets files for use with +makeExample, replace usage of "pre.prettyprint.lang-bash" with this: code-example(format="." language="bash").
fixed spelling errors in examples file path used by +makeExample
changed usage of "code-example" to "+makeExample"
adding code example/snippets files used in toh 1
fixed example file paths, replaced "pre.prettyprint.lang-bash" with "code-example. "
(docs) toh-pt3 initial state
created code examples for display in jade, starting conversion of Google doc and trying +makeExample rendering
all text copied from doc to jade, still some styling and formatting to perform
completed conversion and styling, moved toh3 example files to "tutorial" folder under _examples
created specific code example files for chapter toh 3 and re-pathed references in +makeExample
minor edit
docs) toh combined - initial combined commit
updated ToH for a.52
tons of changes, including de-kebab-ing, removed src folder, updated tsconfig too
fixing snippets using incorrect ending input tag
using inline html and css for the app.component.
ToH Part 1 Code: updated the imports, removed obsolete directive delcarations
ToH Code Part 1: updated to use imports, interface. will hit others soon
toh part 1: ngModel fix
toh part1: removed obsolete story that referred to how we used to have to import and declare all directives we used. yay!
ToH Part 1: updated to use `boot.ts` and `app.component.ts`. this affected the partials, snippets, and the story.
toh part 1: using `npm run go`
toh parts 1 -4: modified all places to use `npm run go`
toh part 1: refactor for jade
toh part 1: fixing the code samples
toh part 2: seeping through the story
toh part 2: fixing snippets.
toh part 2: replaced ngClass with class.selected
toh part 2: removed whitespace
toh part 2: added final state to the code
toh: fixing paths
toh part 4: fixing src/app path to app
toh part 3: fixing folder path
toh part 2: fixed typo
toh part 2: typo on ngModel
toh part 2: added ngif
toh part 2: removed old hero property. moved the details lower, where we need it
toh index: updated hero list image to show consistent styling as the other images here
QS spelling error (targes -> targets)
tweeks: space and ngIF
2015-11-15 21:04:43 -05:00
|
|
|
|
:marked
|
2016-03-24 08:31:27 -04:00
|
|
|
|
Now that we have a `Hero` class, let’s refactor our component’s `hero` property to be of type `Hero`.
|
docs(tutorial): combines all 4 sections + revisions/updates to a.53, hides 3&4
closes #488
ToH History (oldest-to-latest):
----------------------------
created code example/snippets files for use with +makeExample, replace usage of "pre.prettyprint.lang-bash" with this: code-example(format="." language="bash").
fixed spelling errors in examples file path used by +makeExample
changed usage of "code-example" to "+makeExample"
adding code example/snippets files used in toh 1
fixed example file paths, replaced "pre.prettyprint.lang-bash" with "code-example. "
(docs) toh-pt3 initial state
created code examples for display in jade, starting conversion of Google doc and trying +makeExample rendering
all text copied from doc to jade, still some styling and formatting to perform
completed conversion and styling, moved toh3 example files to "tutorial" folder under _examples
created specific code example files for chapter toh 3 and re-pathed references in +makeExample
minor edit
docs) toh combined - initial combined commit
updated ToH for a.52
tons of changes, including de-kebab-ing, removed src folder, updated tsconfig too
fixing snippets using incorrect ending input tag
using inline html and css for the app.component.
ToH Part 1 Code: updated the imports, removed obsolete directive delcarations
ToH Code Part 1: updated to use imports, interface. will hit others soon
toh part 1: ngModel fix
toh part1: removed obsolete story that referred to how we used to have to import and declare all directives we used. yay!
ToH Part 1: updated to use `boot.ts` and `app.component.ts`. this affected the partials, snippets, and the story.
toh part 1: using `npm run go`
toh parts 1 -4: modified all places to use `npm run go`
toh part 1: refactor for jade
toh part 1: fixing the code samples
toh part 2: seeping through the story
toh part 2: fixing snippets.
toh part 2: replaced ngClass with class.selected
toh part 2: removed whitespace
toh part 2: added final state to the code
toh: fixing paths
toh part 4: fixing src/app path to app
toh part 3: fixing folder path
toh part 2: fixed typo
toh part 2: typo on ngModel
toh part 2: added ngif
toh part 2: removed old hero property. moved the details lower, where we need it
toh index: updated hero list image to show consistent styling as the other images here
QS spelling error (targes -> targets)
tweeks: space and ngIF
2015-11-15 21:04:43 -05:00
|
|
|
|
Then initialize it with an id of `1` and the name, "Windstorm".
|
2016-04-12 07:07:06 -04:00
|
|
|
|
|
|
|
|
|
现在,有了一个`Hero`类,我们就要把组件`hero`属性的类型换成`Hero`了。
|
|
|
|
|
然后把`1`作为id、把“Windstorm”作为名字,初始化它。
|
2015-10-15 03:51:24 -04:00
|
|
|
|
|
2016-04-12 07:07:06 -04:00
|
|
|
|
+makeExample('toh-1/ts-snippets/app.component.snippets.pt1.ts', 'hero-property-1', 'app.component.ts (Hero属性)')(format=".")
|
2015-10-15 03:51:24 -04:00
|
|
|
|
|
docs(tutorial): combines all 4 sections + revisions/updates to a.53, hides 3&4
closes #488
ToH History (oldest-to-latest):
----------------------------
created code example/snippets files for use with +makeExample, replace usage of "pre.prettyprint.lang-bash" with this: code-example(format="." language="bash").
fixed spelling errors in examples file path used by +makeExample
changed usage of "code-example" to "+makeExample"
adding code example/snippets files used in toh 1
fixed example file paths, replaced "pre.prettyprint.lang-bash" with "code-example. "
(docs) toh-pt3 initial state
created code examples for display in jade, starting conversion of Google doc and trying +makeExample rendering
all text copied from doc to jade, still some styling and formatting to perform
completed conversion and styling, moved toh3 example files to "tutorial" folder under _examples
created specific code example files for chapter toh 3 and re-pathed references in +makeExample
minor edit
docs) toh combined - initial combined commit
updated ToH for a.52
tons of changes, including de-kebab-ing, removed src folder, updated tsconfig too
fixing snippets using incorrect ending input tag
using inline html and css for the app.component.
ToH Part 1 Code: updated the imports, removed obsolete directive delcarations
ToH Code Part 1: updated to use imports, interface. will hit others soon
toh part 1: ngModel fix
toh part1: removed obsolete story that referred to how we used to have to import and declare all directives we used. yay!
ToH Part 1: updated to use `boot.ts` and `app.component.ts`. this affected the partials, snippets, and the story.
toh part 1: using `npm run go`
toh parts 1 -4: modified all places to use `npm run go`
toh part 1: refactor for jade
toh part 1: fixing the code samples
toh part 2: seeping through the story
toh part 2: fixing snippets.
toh part 2: replaced ngClass with class.selected
toh part 2: removed whitespace
toh part 2: added final state to the code
toh: fixing paths
toh part 4: fixing src/app path to app
toh part 3: fixing folder path
toh part 2: fixed typo
toh part 2: typo on ngModel
toh part 2: added ngif
toh part 2: removed old hero property. moved the details lower, where we need it
toh index: updated hero list image to show consistent styling as the other images here
QS spelling error (targes -> targets)
tweeks: space and ngIF
2015-11-15 21:04:43 -05:00
|
|
|
|
: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.
|
2015-10-15 03:51:24 -04:00
|
|
|
|
|
2016-04-12 07:07:06 -04:00
|
|
|
|
我们把hero从一个字符串换成了对象,于是我们也得更新模板中的绑定表达式,来引用hero的`name`属性。
|
|
|
|
|
|
2015-12-14 23:05:13 -05:00
|
|
|
|
+makeExample('toh-1/ts-snippets/app.component.snippets.pt1.ts', 'show-hero-2')
|
docs(tutorial): combines all 4 sections + revisions/updates to a.53, hides 3&4
closes #488
ToH History (oldest-to-latest):
----------------------------
created code example/snippets files for use with +makeExample, replace usage of "pre.prettyprint.lang-bash" with this: code-example(format="." language="bash").
fixed spelling errors in examples file path used by +makeExample
changed usage of "code-example" to "+makeExample"
adding code example/snippets files used in toh 1
fixed example file paths, replaced "pre.prettyprint.lang-bash" with "code-example. "
(docs) toh-pt3 initial state
created code examples for display in jade, starting conversion of Google doc and trying +makeExample rendering
all text copied from doc to jade, still some styling and formatting to perform
completed conversion and styling, moved toh3 example files to "tutorial" folder under _examples
created specific code example files for chapter toh 3 and re-pathed references in +makeExample
minor edit
docs) toh combined - initial combined commit
updated ToH for a.52
tons of changes, including de-kebab-ing, removed src folder, updated tsconfig too
fixing snippets using incorrect ending input tag
using inline html and css for the app.component.
ToH Part 1 Code: updated the imports, removed obsolete directive delcarations
ToH Code Part 1: updated to use imports, interface. will hit others soon
toh part 1: ngModel fix
toh part1: removed obsolete story that referred to how we used to have to import and declare all directives we used. yay!
ToH Part 1: updated to use `boot.ts` and `app.component.ts`. this affected the partials, snippets, and the story.
toh part 1: using `npm run go`
toh parts 1 -4: modified all places to use `npm run go`
toh part 1: refactor for jade
toh part 1: fixing the code samples
toh part 2: seeping through the story
toh part 2: fixing snippets.
toh part 2: replaced ngClass with class.selected
toh part 2: removed whitespace
toh part 2: added final state to the code
toh: fixing paths
toh part 4: fixing src/app path to app
toh part 3: fixing folder path
toh part 2: fixed typo
toh part 2: typo on ngModel
toh part 2: added ngif
toh part 2: removed old hero property. moved the details lower, where we need it
toh index: updated hero list image to show consistent styling as the other images here
QS spelling error (targes -> targets)
tweeks: space and ngIF
2015-11-15 21:04:43 -05:00
|
|
|
|
:marked
|
|
|
|
|
The browser refreshes and continues to display our hero’s name.
|
2016-04-12 07:07:06 -04:00
|
|
|
|
|
|
|
|
|
浏览器自动刷新,并且继续显示这位英雄的名字。
|
2015-10-15 03:51:24 -04:00
|
|
|
|
|
docs(tutorial): combines all 4 sections + revisions/updates to a.53, hides 3&4
closes #488
ToH History (oldest-to-latest):
----------------------------
created code example/snippets files for use with +makeExample, replace usage of "pre.prettyprint.lang-bash" with this: code-example(format="." language="bash").
fixed spelling errors in examples file path used by +makeExample
changed usage of "code-example" to "+makeExample"
adding code example/snippets files used in toh 1
fixed example file paths, replaced "pre.prettyprint.lang-bash" with "code-example. "
(docs) toh-pt3 initial state
created code examples for display in jade, starting conversion of Google doc and trying +makeExample rendering
all text copied from doc to jade, still some styling and formatting to perform
completed conversion and styling, moved toh3 example files to "tutorial" folder under _examples
created specific code example files for chapter toh 3 and re-pathed references in +makeExample
minor edit
docs) toh combined - initial combined commit
updated ToH for a.52
tons of changes, including de-kebab-ing, removed src folder, updated tsconfig too
fixing snippets using incorrect ending input tag
using inline html and css for the app.component.
ToH Part 1 Code: updated the imports, removed obsolete directive delcarations
ToH Code Part 1: updated to use imports, interface. will hit others soon
toh part 1: ngModel fix
toh part1: removed obsolete story that referred to how we used to have to import and declare all directives we used. yay!
ToH Part 1: updated to use `boot.ts` and `app.component.ts`. this affected the partials, snippets, and the story.
toh part 1: using `npm run go`
toh parts 1 -4: modified all places to use `npm run go`
toh part 1: refactor for jade
toh part 1: fixing the code samples
toh part 2: seeping through the story
toh part 2: fixing snippets.
toh part 2: replaced ngClass with class.selected
toh part 2: removed whitespace
toh part 2: added final state to the code
toh: fixing paths
toh part 4: fixing src/app path to app
toh part 3: fixing folder path
toh part 2: fixed typo
toh part 2: typo on ngModel
toh part 2: added ngif
toh part 2: removed old hero property. moved the details lower, where we need it
toh index: updated hero list image to show consistent styling as the other images here
QS spelling error (targes -> targets)
tweeks: space and ngIF
2015-11-15 21:04:43 -05:00
|
|
|
|
### Adding more HTML
|
2016-04-12 07:07:06 -04:00
|
|
|
|
### 添加更多的HTML
|
docs(tutorial): combines all 4 sections + revisions/updates to a.53, hides 3&4
closes #488
ToH History (oldest-to-latest):
----------------------------
created code example/snippets files for use with +makeExample, replace usage of "pre.prettyprint.lang-bash" with this: code-example(format="." language="bash").
fixed spelling errors in examples file path used by +makeExample
changed usage of "code-example" to "+makeExample"
adding code example/snippets files used in toh 1
fixed example file paths, replaced "pre.prettyprint.lang-bash" with "code-example. "
(docs) toh-pt3 initial state
created code examples for display in jade, starting conversion of Google doc and trying +makeExample rendering
all text copied from doc to jade, still some styling and formatting to perform
completed conversion and styling, moved toh3 example files to "tutorial" folder under _examples
created specific code example files for chapter toh 3 and re-pathed references in +makeExample
minor edit
docs) toh combined - initial combined commit
updated ToH for a.52
tons of changes, including de-kebab-ing, removed src folder, updated tsconfig too
fixing snippets using incorrect ending input tag
using inline html and css for the app.component.
ToH Part 1 Code: updated the imports, removed obsolete directive delcarations
ToH Code Part 1: updated to use imports, interface. will hit others soon
toh part 1: ngModel fix
toh part1: removed obsolete story that referred to how we used to have to import and declare all directives we used. yay!
ToH Part 1: updated to use `boot.ts` and `app.component.ts`. this affected the partials, snippets, and the story.
toh part 1: using `npm run go`
toh parts 1 -4: modified all places to use `npm run go`
toh part 1: refactor for jade
toh part 1: fixing the code samples
toh part 2: seeping through the story
toh part 2: fixing snippets.
toh part 2: replaced ngClass with class.selected
toh part 2: removed whitespace
toh part 2: added final state to the code
toh: fixing paths
toh part 4: fixing src/app path to app
toh part 3: fixing folder path
toh part 2: fixed typo
toh part 2: typo on ngModel
toh part 2: added ngif
toh part 2: removed old hero property. moved the details lower, where we need it
toh index: updated hero list image to show consistent styling as the other images here
QS spelling error (targes -> targets)
tweeks: space and ngIF
2015-11-15 21:04:43 -05:00
|
|
|
|
Displaying a name is good, but we want to see all of our hero’s properties.
|
|
|
|
|
We’ll add a `<div>` for our hero’s `id` property and another `<div>` for our hero’s `name`.
|
2015-10-15 03:51:24 -04:00
|
|
|
|
|
2016-04-14 09:45:12 -04:00
|
|
|
|
能显示名字就算不错了,但是我们还想看到我们这位英雄的所有属性。
|
|
|
|
|
我们将添加一个`<div>`来显示英雄的`id`属性,另一个`<div>`来显示英雄的`name`属性。
|
2016-04-12 07:07:06 -04:00
|
|
|
|
|
2015-12-14 23:05:13 -05:00
|
|
|
|
+makeExample('toh-1/ts-snippets/app.component.snippets.pt1.ts', 'show-hero-properties')
|
docs(tutorial): combines all 4 sections + revisions/updates to a.53, hides 3&4
closes #488
ToH History (oldest-to-latest):
----------------------------
created code example/snippets files for use with +makeExample, replace usage of "pre.prettyprint.lang-bash" with this: code-example(format="." language="bash").
fixed spelling errors in examples file path used by +makeExample
changed usage of "code-example" to "+makeExample"
adding code example/snippets files used in toh 1
fixed example file paths, replaced "pre.prettyprint.lang-bash" with "code-example. "
(docs) toh-pt3 initial state
created code examples for display in jade, starting conversion of Google doc and trying +makeExample rendering
all text copied from doc to jade, still some styling and formatting to perform
completed conversion and styling, moved toh3 example files to "tutorial" folder under _examples
created specific code example files for chapter toh 3 and re-pathed references in +makeExample
minor edit
docs) toh combined - initial combined commit
updated ToH for a.52
tons of changes, including de-kebab-ing, removed src folder, updated tsconfig too
fixing snippets using incorrect ending input tag
using inline html and css for the app.component.
ToH Part 1 Code: updated the imports, removed obsolete directive delcarations
ToH Code Part 1: updated to use imports, interface. will hit others soon
toh part 1: ngModel fix
toh part1: removed obsolete story that referred to how we used to have to import and declare all directives we used. yay!
ToH Part 1: updated to use `boot.ts` and `app.component.ts`. this affected the partials, snippets, and the story.
toh part 1: using `npm run go`
toh parts 1 -4: modified all places to use `npm run go`
toh part 1: refactor for jade
toh part 1: fixing the code samples
toh part 2: seeping through the story
toh part 2: fixing snippets.
toh part 2: replaced ngClass with class.selected
toh part 2: removed whitespace
toh part 2: added final state to the code
toh: fixing paths
toh part 4: fixing src/app path to app
toh part 3: fixing folder path
toh part 2: fixed typo
toh part 2: typo on ngModel
toh part 2: added ngif
toh part 2: removed old hero property. moved the details lower, where we need it
toh index: updated hero list image to show consistent styling as the other images here
QS spelling error (targes -> targets)
tweeks: space and ngIF
2015-11-15 21:04:43 -05:00
|
|
|
|
: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.
|
2016-04-12 07:07:06 -04:00
|
|
|
|
|
|
|
|
|
啊哦!我们的模板字符串已经太长了。我们最好小心点,免得在模板中出现拼写错误。
|
2015-10-15 03:51:24 -04:00
|
|
|
|
|
docs(tutorial): combines all 4 sections + revisions/updates to a.53, hides 3&4
closes #488
ToH History (oldest-to-latest):
----------------------------
created code example/snippets files for use with +makeExample, replace usage of "pre.prettyprint.lang-bash" with this: code-example(format="." language="bash").
fixed spelling errors in examples file path used by +makeExample
changed usage of "code-example" to "+makeExample"
adding code example/snippets files used in toh 1
fixed example file paths, replaced "pre.prettyprint.lang-bash" with "code-example. "
(docs) toh-pt3 initial state
created code examples for display in jade, starting conversion of Google doc and trying +makeExample rendering
all text copied from doc to jade, still some styling and formatting to perform
completed conversion and styling, moved toh3 example files to "tutorial" folder under _examples
created specific code example files for chapter toh 3 and re-pathed references in +makeExample
minor edit
docs) toh combined - initial combined commit
updated ToH for a.52
tons of changes, including de-kebab-ing, removed src folder, updated tsconfig too
fixing snippets using incorrect ending input tag
using inline html and css for the app.component.
ToH Part 1 Code: updated the imports, removed obsolete directive delcarations
ToH Code Part 1: updated to use imports, interface. will hit others soon
toh part 1: ngModel fix
toh part1: removed obsolete story that referred to how we used to have to import and declare all directives we used. yay!
ToH Part 1: updated to use `boot.ts` and `app.component.ts`. this affected the partials, snippets, and the story.
toh part 1: using `npm run go`
toh parts 1 -4: modified all places to use `npm run go`
toh part 1: refactor for jade
toh part 1: fixing the code samples
toh part 2: seeping through the story
toh part 2: fixing snippets.
toh part 2: replaced ngClass with class.selected
toh part 2: removed whitespace
toh part 2: added final state to the code
toh: fixing paths
toh part 4: fixing src/app path to app
toh part 3: fixing folder path
toh part 2: fixed typo
toh part 2: typo on ngModel
toh part 2: added ngif
toh part 2: removed old hero property. moved the details lower, where we need it
toh index: updated hero list image to show consistent styling as the other images here
QS spelling error (targes -> targets)
tweeks: space and ngIF
2015-11-15 21:04:43 -05:00
|
|
|
|
### Multi-line template strings
|
2016-04-12 07:07:06 -04:00
|
|
|
|
### 多行模板字符串
|
2015-10-15 03:51:24 -04:00
|
|
|
|
|
docs(tutorial): combines all 4 sections + revisions/updates to a.53, hides 3&4
closes #488
ToH History (oldest-to-latest):
----------------------------
created code example/snippets files for use with +makeExample, replace usage of "pre.prettyprint.lang-bash" with this: code-example(format="." language="bash").
fixed spelling errors in examples file path used by +makeExample
changed usage of "code-example" to "+makeExample"
adding code example/snippets files used in toh 1
fixed example file paths, replaced "pre.prettyprint.lang-bash" with "code-example. "
(docs) toh-pt3 initial state
created code examples for display in jade, starting conversion of Google doc and trying +makeExample rendering
all text copied from doc to jade, still some styling and formatting to perform
completed conversion and styling, moved toh3 example files to "tutorial" folder under _examples
created specific code example files for chapter toh 3 and re-pathed references in +makeExample
minor edit
docs) toh combined - initial combined commit
updated ToH for a.52
tons of changes, including de-kebab-ing, removed src folder, updated tsconfig too
fixing snippets using incorrect ending input tag
using inline html and css for the app.component.
ToH Part 1 Code: updated the imports, removed obsolete directive delcarations
ToH Code Part 1: updated to use imports, interface. will hit others soon
toh part 1: ngModel fix
toh part1: removed obsolete story that referred to how we used to have to import and declare all directives we used. yay!
ToH Part 1: updated to use `boot.ts` and `app.component.ts`. this affected the partials, snippets, and the story.
toh part 1: using `npm run go`
toh parts 1 -4: modified all places to use `npm run go`
toh part 1: refactor for jade
toh part 1: fixing the code samples
toh part 2: seeping through the story
toh part 2: fixing snippets.
toh part 2: replaced ngClass with class.selected
toh part 2: removed whitespace
toh part 2: added final state to the code
toh: fixing paths
toh part 4: fixing src/app path to app
toh part 3: fixing folder path
toh part 2: fixed typo
toh part 2: typo on ngModel
toh part 2: added ngif
toh part 2: removed old hero property. moved the details lower, where we need it
toh index: updated hero list image to show consistent styling as the other images here
QS spelling error (targes -> targets)
tweeks: space and ngIF
2015-11-15 21:04:43 -05:00
|
|
|
|
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.
|
2015-10-15 03:51:24 -04:00
|
|
|
|
|
2016-04-12 07:07:06 -04:00
|
|
|
|
我们可以通过字符串加法来制作更可读的模板,但这样仍然太难看了 —— 难于阅读,容易出现拼写错误。
|
|
|
|
|
这样不行!我们要借助ES2015和TypeScript提供的模板字符串来保持清醒。
|
|
|
|
|
|
docs(tutorial): combines all 4 sections + revisions/updates to a.53, hides 3&4
closes #488
ToH History (oldest-to-latest):
----------------------------
created code example/snippets files for use with +makeExample, replace usage of "pre.prettyprint.lang-bash" with this: code-example(format="." language="bash").
fixed spelling errors in examples file path used by +makeExample
changed usage of "code-example" to "+makeExample"
adding code example/snippets files used in toh 1
fixed example file paths, replaced "pre.prettyprint.lang-bash" with "code-example. "
(docs) toh-pt3 initial state
created code examples for display in jade, starting conversion of Google doc and trying +makeExample rendering
all text copied from doc to jade, still some styling and formatting to perform
completed conversion and styling, moved toh3 example files to "tutorial" folder under _examples
created specific code example files for chapter toh 3 and re-pathed references in +makeExample
minor edit
docs) toh combined - initial combined commit
updated ToH for a.52
tons of changes, including de-kebab-ing, removed src folder, updated tsconfig too
fixing snippets using incorrect ending input tag
using inline html and css for the app.component.
ToH Part 1 Code: updated the imports, removed obsolete directive delcarations
ToH Code Part 1: updated to use imports, interface. will hit others soon
toh part 1: ngModel fix
toh part1: removed obsolete story that referred to how we used to have to import and declare all directives we used. yay!
ToH Part 1: updated to use `boot.ts` and `app.component.ts`. this affected the partials, snippets, and the story.
toh part 1: using `npm run go`
toh parts 1 -4: modified all places to use `npm run go`
toh part 1: refactor for jade
toh part 1: fixing the code samples
toh part 2: seeping through the story
toh part 2: fixing snippets.
toh part 2: replaced ngClass with class.selected
toh part 2: removed whitespace
toh part 2: added final state to the code
toh: fixing paths
toh part 4: fixing src/app path to app
toh part 3: fixing folder path
toh part 2: fixed typo
toh part 2: typo on ngModel
toh part 2: added ngif
toh part 2: removed old hero property. moved the details lower, where we need it
toh index: updated hero list image to show consistent styling as the other images here
QS spelling error (targes -> targets)
tweeks: space and ngIF
2015-11-15 21:04:43 -05:00
|
|
|
|
Change the quotes around the template to back-ticks and
|
|
|
|
|
put the `<h1>`, `<h2>` and `<div>` elements on their own lines.
|
|
|
|
|
|
2016-04-12 07:07:06 -04:00
|
|
|
|
把模板的双引号改成反引号,并且让`<h1>`, `<h2>` 和 `<div>`标签各占一行。
|
|
|
|
|
|
|
|
|
|
+makeExample('toh-1/ts-snippets/app.component.snippets.pt1.ts', 'multi-line-strings', 'app.component.ts (AppComponent的 模板)')
|
2015-10-15 03:51:24 -04:00
|
|
|
|
|
|
|
|
|
.callout.is-important
|
|
|
|
|
header A back-tick is not a single quote
|
2016-04-12 07:07:06 -04:00
|
|
|
|
header 反引号不是单引号
|
2015-11-10 13:31:46 -05:00
|
|
|
|
:marked
|
2015-10-15 03:51:24 -04:00
|
|
|
|
**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.
|
2016-04-12 07:07:06 -04:00
|
|
|
|
|
|
|
|
|
**小心!**反引号(`)看起来很像单引号('),但它们是截然不同的字符。
|
|
|
|
|
反引号能够做的可不只是标记字符串边界。
|
|
|
|
|
在这里,我们只用它来把我们的模板变成多行的,而不涉及更多用途。
|
|
|
|
|
所有被反引号引起来的部分,都是一个单一模板字符串的一部分。
|
2015-10-15 03:51:24 -04:00
|
|
|
|
|
|
|
|
|
.l-main-section
|
2015-12-14 23:05:13 -05:00
|
|
|
|
:marked
|
|
|
|
|
## Editing Our Hero
|
2016-04-12 07:07:06 -04:00
|
|
|
|
## 编辑我们的英雄
|
2015-10-15 03:51:24 -04:00
|
|
|
|
|
2015-12-14 23:05:13 -05:00
|
|
|
|
We want to be able to edit the hero name in a textbox.
|
2016-04-12 07:07:06 -04:00
|
|
|
|
|
|
|
|
|
我们想在一个文本框中编辑英雄的名字。
|
2015-10-15 03:51:24 -04:00
|
|
|
|
|
2015-12-14 23:05:13 -05:00
|
|
|
|
Refactor the hero name `<label>` with `<label>` and `<input>` elements as shown below:
|
docs(tutorial): combines all 4 sections + revisions/updates to a.53, hides 3&4
closes #488
ToH History (oldest-to-latest):
----------------------------
created code example/snippets files for use with +makeExample, replace usage of "pre.prettyprint.lang-bash" with this: code-example(format="." language="bash").
fixed spelling errors in examples file path used by +makeExample
changed usage of "code-example" to "+makeExample"
adding code example/snippets files used in toh 1
fixed example file paths, replaced "pre.prettyprint.lang-bash" with "code-example. "
(docs) toh-pt3 initial state
created code examples for display in jade, starting conversion of Google doc and trying +makeExample rendering
all text copied from doc to jade, still some styling and formatting to perform
completed conversion and styling, moved toh3 example files to "tutorial" folder under _examples
created specific code example files for chapter toh 3 and re-pathed references in +makeExample
minor edit
docs) toh combined - initial combined commit
updated ToH for a.52
tons of changes, including de-kebab-ing, removed src folder, updated tsconfig too
fixing snippets using incorrect ending input tag
using inline html and css for the app.component.
ToH Part 1 Code: updated the imports, removed obsolete directive delcarations
ToH Code Part 1: updated to use imports, interface. will hit others soon
toh part 1: ngModel fix
toh part1: removed obsolete story that referred to how we used to have to import and declare all directives we used. yay!
ToH Part 1: updated to use `boot.ts` and `app.component.ts`. this affected the partials, snippets, and the story.
toh part 1: using `npm run go`
toh parts 1 -4: modified all places to use `npm run go`
toh part 1: refactor for jade
toh part 1: fixing the code samples
toh part 2: seeping through the story
toh part 2: fixing snippets.
toh part 2: replaced ngClass with class.selected
toh part 2: removed whitespace
toh part 2: added final state to the code
toh: fixing paths
toh part 4: fixing src/app path to app
toh part 3: fixing folder path
toh part 2: fixed typo
toh part 2: typo on ngModel
toh part 2: added ngif
toh part 2: removed old hero property. moved the details lower, where we need it
toh index: updated hero list image to show consistent styling as the other images here
QS spelling error (targes -> targets)
tweeks: space and ngIF
2015-11-15 21:04:43 -05:00
|
|
|
|
|
2016-04-12 07:07:06 -04:00
|
|
|
|
重构英雄的名字,从单纯的`<label>`到`<label>`和`<input>`元素的组合,就像下面这样:
|
|
|
|
|
|
|
|
|
|
+makeExample('toh-1/ts-snippets/app.component.snippets.pt1.ts', 'editing-Hero', 'app.component.ts (input元素)')
|
2015-12-14 23:05:13 -05:00
|
|
|
|
:marked
|
|
|
|
|
We see in the browser that the hero’s name does appear in the `<input>` textbox.
|
|
|
|
|
But something doesn’t feel right.
|
|
|
|
|
When we change the name, we notice that our change
|
|
|
|
|
is not reflected in the `<h2>`. We won't get the desired behavior
|
|
|
|
|
with a one-way binding to `<input>`.
|
2015-10-15 03:51:24 -04:00
|
|
|
|
|
2016-04-12 07:07:06 -04:00
|
|
|
|
在浏览器中,我们看到英雄的名字显示为了一个`<input>`文本框。但看起来还是有些不太对。
|
|
|
|
|
当修改名字时,我们的改动并没有反映到`<h2>`中。使用单向数据绑定,我们没法实现所期望的行为。
|
|
|
|
|
|
2015-12-14 23:05:13 -05:00
|
|
|
|
### Two-Way Binding
|
2016-04-12 07:07:06 -04:00
|
|
|
|
### 双向绑定
|
2015-10-15 03:51:24 -04:00
|
|
|
|
|
2015-12-14 23:05:13 -05:00
|
|
|
|
We intend to display the name of the hero in the `<input>`, change it,
|
|
|
|
|
and see those changes wherever we bind to the hero’s name.
|
|
|
|
|
In short, we want two-way data binding.
|
2015-10-15 03:51:24 -04:00
|
|
|
|
|
2016-04-12 07:07:06 -04:00
|
|
|
|
我们的期望是:在`<input>`中显示英雄的名字,修改它,并且在所有绑定到英雄名字的地方看到这些修改。
|
|
|
|
|
长话短说:我们需要双向数据绑定。
|
|
|
|
|
|
2015-12-14 23:05:13 -05:00
|
|
|
|
Let’s update the template to use the **`ngModel`** built-in directive for two-way binding.
|
2016-04-12 07:07:06 -04:00
|
|
|
|
|
|
|
|
|
让我们通过**`ngModel`**内置指令提供的双向数据绑定机制来更新模板。
|
2015-11-10 13:31:46 -05:00
|
|
|
|
|
2015-12-14 23:05:13 -05:00
|
|
|
|
.l-sub-section
|
2015-11-10 13:31:46 -05:00
|
|
|
|
:marked
|
2015-12-14 23:05:13 -05:00
|
|
|
|
Learn more about `ngModel` in the
|
|
|
|
|
[Forms](../guide/forms.html#ngModel) and
|
|
|
|
|
[Template Syntax](../guide/template-syntax.html#ngModel) chapters.
|
2016-04-12 07:07:06 -04:00
|
|
|
|
|
|
|
|
|
学习`ngModel`的更多知识,参见[表单](../guide/forms.html#ngModel)和
|
|
|
|
|
[模板语法](../guide/template-syntax.html#ngModel)两章
|
2015-12-14 23:05:13 -05:00
|
|
|
|
:marked
|
|
|
|
|
Replace the `<input>` with the following HTML
|
2015-10-15 03:51:24 -04:00
|
|
|
|
|
2016-04-12 07:07:06 -04:00
|
|
|
|
把`<input>`替换为下列HTML
|
|
|
|
|
|
2015-12-14 23:05:13 -05:00
|
|
|
|
code-example(language="html").
|
|
|
|
|
<input [(ngModel)]="hero.name" placeholder="name">
|
|
|
|
|
|
|
|
|
|
:marked
|
|
|
|
|
The browser refreshes. We see our hero again. We can edit the hero’s name and
|
|
|
|
|
see the changes reflected immediately in the `<h2>`.
|
2015-11-10 13:31:46 -05:00
|
|
|
|
|
2016-04-12 07:07:06 -04:00
|
|
|
|
浏览器刷新。再次见到我们的英雄。我们可以编辑英雄的名字,并且看到改动立刻体现在`<h2>`中。
|
|
|
|
|
|
2015-10-16 04:06:56 -04:00
|
|
|
|
.l-main-section
|
2015-12-14 23:05:13 -05:00
|
|
|
|
:marked
|
|
|
|
|
## The Road We’ve Travelled
|
2016-04-12 07:07:06 -04:00
|
|
|
|
## 我们已经走过的路
|
2015-12-14 23:05:13 -05:00
|
|
|
|
Let’s take stock of what we’ve built.
|
2016-04-12 07:07:06 -04:00
|
|
|
|
|
|
|
|
|
我们来清点一下已经构建完成的。
|
2015-12-14 23:05:13 -05:00
|
|
|
|
|
|
|
|
|
* Our Tour of Heroes uses the double curly braces of interpolation (a form of one-way data binding)
|
|
|
|
|
to display the application title and properties of a `Hero` object.
|
2016-04-17 11:31:22 -04:00
|
|
|
|
* 我们的《英雄指南》使用双大括号(插值表达式 —— 单向数据绑定的一种形式)来显示应用的标题和`Hero`对象的属性。
|
2015-12-14 23:05:13 -05:00
|
|
|
|
* We wrote a multi-line template using ES2015’s template strings to make our template readable.
|
2016-04-12 07:07:06 -04:00
|
|
|
|
* 我们使用ES2105的模板字符串写了一个多行模板,来让我们的模板更有可读性。
|
2015-12-14 23:05:13 -05:00
|
|
|
|
* We can both display and change the hero’s name after adding a two-way data binding to the `<input>` element
|
|
|
|
|
using the built-in `ngModel` directive.
|
2016-04-12 07:07:06 -04:00
|
|
|
|
* 为了同时显示和修改英雄的名字,我们还使用了内建的`ngModel`指令,往`<input>`元素上添加双向数据绑定。
|
2015-12-14 23:05:13 -05:00
|
|
|
|
* The `ngModel` directive also propagates changes to every other binding of the `hero.name`.
|
2016-04-12 07:07:06 -04:00
|
|
|
|
* 通过`ngModel`指令,这些修改还影响到`hero.name`的每一个其它的绑定。
|
2015-10-15 03:51:24 -04:00
|
|
|
|
|
2015-12-14 23:05:13 -05:00
|
|
|
|
[Run the live example for part 1](/resources/live-examples/toh-1/ts/plnkr.html)
|
2016-04-12 07:07:06 -04:00
|
|
|
|
|
|
|
|
|
[运行第一部分的鲜活范例](/resources/live-examples/toh-1/ts/plnkr.html)
|
docs(tutorial): combines all 4 sections + revisions/updates to a.53, hides 3&4
closes #488
ToH History (oldest-to-latest):
----------------------------
created code example/snippets files for use with +makeExample, replace usage of "pre.prettyprint.lang-bash" with this: code-example(format="." language="bash").
fixed spelling errors in examples file path used by +makeExample
changed usage of "code-example" to "+makeExample"
adding code example/snippets files used in toh 1
fixed example file paths, replaced "pre.prettyprint.lang-bash" with "code-example. "
(docs) toh-pt3 initial state
created code examples for display in jade, starting conversion of Google doc and trying +makeExample rendering
all text copied from doc to jade, still some styling and formatting to perform
completed conversion and styling, moved toh3 example files to "tutorial" folder under _examples
created specific code example files for chapter toh 3 and re-pathed references in +makeExample
minor edit
docs) toh combined - initial combined commit
updated ToH for a.52
tons of changes, including de-kebab-ing, removed src folder, updated tsconfig too
fixing snippets using incorrect ending input tag
using inline html and css for the app.component.
ToH Part 1 Code: updated the imports, removed obsolete directive delcarations
ToH Code Part 1: updated to use imports, interface. will hit others soon
toh part 1: ngModel fix
toh part1: removed obsolete story that referred to how we used to have to import and declare all directives we used. yay!
ToH Part 1: updated to use `boot.ts` and `app.component.ts`. this affected the partials, snippets, and the story.
toh part 1: using `npm run go`
toh parts 1 -4: modified all places to use `npm run go`
toh part 1: refactor for jade
toh part 1: fixing the code samples
toh part 2: seeping through the story
toh part 2: fixing snippets.
toh part 2: replaced ngClass with class.selected
toh part 2: removed whitespace
toh part 2: added final state to the code
toh: fixing paths
toh part 4: fixing src/app path to app
toh part 3: fixing folder path
toh part 2: fixed typo
toh part 2: typo on ngModel
toh part 2: added ngif
toh part 2: removed old hero property. moved the details lower, where we need it
toh index: updated hero list image to show consistent styling as the other images here
QS spelling error (targes -> targets)
tweeks: space and ngIF
2015-11-15 21:04:43 -05:00
|
|
|
|
|
2015-12-14 23:05:13 -05:00
|
|
|
|
Here's the complete `app.component.ts` as it stands now:
|
2016-04-12 07:07:06 -04:00
|
|
|
|
|
|
|
|
|
完整的`app.component.ts`是这样的:
|
docs(tutorial): combines all 4 sections + revisions/updates to a.53, hides 3&4
closes #488
ToH History (oldest-to-latest):
----------------------------
created code example/snippets files for use with +makeExample, replace usage of "pre.prettyprint.lang-bash" with this: code-example(format="." language="bash").
fixed spelling errors in examples file path used by +makeExample
changed usage of "code-example" to "+makeExample"
adding code example/snippets files used in toh 1
fixed example file paths, replaced "pre.prettyprint.lang-bash" with "code-example. "
(docs) toh-pt3 initial state
created code examples for display in jade, starting conversion of Google doc and trying +makeExample rendering
all text copied from doc to jade, still some styling and formatting to perform
completed conversion and styling, moved toh3 example files to "tutorial" folder under _examples
created specific code example files for chapter toh 3 and re-pathed references in +makeExample
minor edit
docs) toh combined - initial combined commit
updated ToH for a.52
tons of changes, including de-kebab-ing, removed src folder, updated tsconfig too
fixing snippets using incorrect ending input tag
using inline html and css for the app.component.
ToH Part 1 Code: updated the imports, removed obsolete directive delcarations
ToH Code Part 1: updated to use imports, interface. will hit others soon
toh part 1: ngModel fix
toh part1: removed obsolete story that referred to how we used to have to import and declare all directives we used. yay!
ToH Part 1: updated to use `boot.ts` and `app.component.ts`. this affected the partials, snippets, and the story.
toh part 1: using `npm run go`
toh parts 1 -4: modified all places to use `npm run go`
toh part 1: refactor for jade
toh part 1: fixing the code samples
toh part 2: seeping through the story
toh part 2: fixing snippets.
toh part 2: replaced ngClass with class.selected
toh part 2: removed whitespace
toh part 2: added final state to the code
toh: fixing paths
toh part 4: fixing src/app path to app
toh part 3: fixing folder path
toh part 2: fixed typo
toh part 2: typo on ngModel
toh part 2: added ngif
toh part 2: removed old hero property. moved the details lower, where we need it
toh index: updated hero list image to show consistent styling as the other images here
QS spelling error (targes -> targets)
tweeks: space and ngIF
2015-11-15 21:04:43 -05:00
|
|
|
|
|
2015-12-14 23:05:13 -05:00
|
|
|
|
+makeExample('toh-1/ts/app/app.component.ts', 'pt1', 'app.component.ts')
|
2015-11-10 13:31:46 -05:00
|
|
|
|
|
2015-10-16 04:06:56 -04:00
|
|
|
|
.l-main-section
|
2015-12-14 23:05:13 -05:00
|
|
|
|
:marked
|
|
|
|
|
## The Road Ahead
|
2016-04-12 07:07:06 -04:00
|
|
|
|
## 前方的路
|
2015-12-14 23:05:13 -05:00
|
|
|
|
Our Tour of Heroes only displays one hero and we really want to display a list of heroes.
|
|
|
|
|
We also want to allow the user to select a hero and display their details.
|
|
|
|
|
We’ll learn more about how to retrieve lists, bind them to the
|
|
|
|
|
template, and allow a user to select it in the
|
2016-04-12 07:07:06 -04:00
|
|
|
|
[next tutorial chapter](./toh-pt2.html).
|
|
|
|
|
|
2016-04-17 11:31:22 -04:00
|
|
|
|
我们的《英雄指南》只显示了一个英雄,而我们真正想显示的是一个英雄列表。
|
2016-05-09 09:50:33 -04:00
|
|
|
|
我们还希望允许用户选择一个英雄,并且显示他的详情。
|
2016-04-12 07:07:06 -04:00
|
|
|
|
我们还将学习更多:接收一个列表、把它们绑定到模板,以及让用户选择它。
|
|
|
|
|
这些都在[教程的下一章](./toh-pt2.html)。
|