2016-02-05 23:27:06 -08:00
|
|
|
|
include ../_util-fns
|
2015-10-15 00:51:24 -07: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 18:04:43 -08:00
|
|
|
|
:marked
|
2016-11-26 21:43:16 +00:00
|
|
|
|
## Setup to develop locally
|
2017-04-15 15:34:47 +08:00
|
|
|
|
|
2016-11-26 21:43:16 +00:00
|
|
|
|
## 为本地开发搭建环境
|
2017-04-15 15:34:47 +08:00
|
|
|
|
|
2016-11-26 21:43:16 +00:00
|
|
|
|
Follow the [setup](../guide/setup.html) instructions for creating a new project
|
2017-03-31 01:13:42 +02:00
|
|
|
|
named <code>angular-tour-of-heroes</code>.
|
2017-04-15 15:34:47 +08:00
|
|
|
|
|
|
|
|
|
根据[开发环境](../guide/setup.html)中的说明创建一个名为<ngio-ex path="angular-tour-of-heroes"></ngio-ex>的新项目
|
2017-03-21 11:08:09 -07:00
|
|
|
|
|
|
|
|
|
The file structure should look like this:
|
2015-12-14 20:05:13 -08:00
|
|
|
|
|
2016-11-26 21:43:16 +00:00
|
|
|
|
该项目的文件结构应该是这样的:
|
2015-10-15 00:51:24 -07:00
|
|
|
|
|
2015-12-14 20:05:13 -08:00
|
|
|
|
.filetree
|
2016-09-20 05:24:40 +02:00
|
|
|
|
.file angular-tour-of-heroes
|
2015-12-14 20:05:13 -08:00
|
|
|
|
.children
|
2017-02-02 18:38:17 +00:00
|
|
|
|
.file src
|
2015-12-14 20:05:13 -08:00
|
|
|
|
.children
|
2017-02-02 18:38:17 +00:00
|
|
|
|
.file app
|
|
|
|
|
.children
|
|
|
|
|
.file app.component.ts
|
|
|
|
|
.file app.module.ts
|
2016-01-28 16:15:26 -08:00
|
|
|
|
.file main.ts
|
2017-02-02 18:38:17 +00:00
|
|
|
|
.file index.html
|
|
|
|
|
.file styles.css
|
|
|
|
|
.file systemjs.config.js
|
|
|
|
|
.file tsconfig.json
|
2017-03-21 11:08:09 -07:00
|
|
|
|
.file node_modules ...
|
2015-12-14 20:05:13 -08:00
|
|
|
|
.file package.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 18:04:43 -08:00
|
|
|
|
:marked
|
2017-03-21 11:08:09 -07:00
|
|
|
|
When you're done with this page, the app should look like this <live-example></live-example>.
|
2016-11-26 21:43:16 +00:00
|
|
|
|
|
2017-04-23 09:34:51 +08:00
|
|
|
|
在我们完成本章时,得到的应用和这个<live-example></live-example>一样。
|
2016-11-26 21:43:16 +00:00
|
|
|
|
|
2017-03-21 11:08:09 -07:00
|
|
|
|
a#keep-transpiling
|
|
|
|
|
: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 18:04:43 -08:00
|
|
|
|
## Keep the app transpiling and running
|
2017-04-15 15:34:47 +08:00
|
|
|
|
|
2016-04-12 19:07:06 +08:00
|
|
|
|
## 保持应用不断转译和运行
|
2017-04-15 15:34:47 +08:00
|
|
|
|
|
2017-03-21 11:08:09 -07:00
|
|
|
|
Enter the following command in the terminal window:
|
2017-04-15 15:34:47 +08:00
|
|
|
|
|
2016-12-01 15:08:04 +08:00
|
|
|
|
在命令行窗口中输入以下命令:
|
2015-10-15 00:51:24 -07:00
|
|
|
|
|
2016-11-26 21:43:16 +00:00
|
|
|
|
code-example(language="sh" class="code-shell").
|
2015-12-16 08:16:16 -08:00
|
|
|
|
npm start
|
2015-10-15 00:51:24 -07: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 18:04:43 -08:00
|
|
|
|
:marked
|
2017-03-21 11:08:09 -07:00
|
|
|
|
This command runs the TypeScript compiler in "watch mode", recompiling automatically when the code changes.
|
|
|
|
|
The command simultaneously launches the app in a browser and refreshes the browser when the code changes.
|
2017-04-15 23:34:54 +08:00
|
|
|
|
|
2017-05-07 11:36:33 +08:00
|
|
|
|
这个命令会在“监听”模式下运行TypeScript编译器,当代码变化时,它会自动重新编译。
|
2017-04-15 23:34:54 +08:00
|
|
|
|
同时,该命令还会在浏览器中启动该应用,并且当代码变化时刷新浏览器。
|
2017-03-21 11:08:09 -07:00
|
|
|
|
|
|
|
|
|
You can keep building the Tour of Heroes without pausing to recompile or refresh the browser.
|
2015-10-15 00:51:24 -07:00
|
|
|
|
|
2017-04-15 23:34:54 +08:00
|
|
|
|
在后续构建《英雄指南》过程中,应用能持续运行,而不用中断服务来编译或刷新浏览器。
|
2016-11-22 20:07:16 +08:00
|
|
|
|
|
2015-10-15 00:51:24 -07:00
|
|
|
|
.l-main-section
|
2015-11-10 18:31:46 +00:00
|
|
|
|
:marked
|
2017-03-21 11:08:09 -07:00
|
|
|
|
## Show the hero
|
2017-04-15 15:34:47 +08:00
|
|
|
|
|
|
|
|
|
## 显示此英雄
|
|
|
|
|
|
2017-03-21 11:08:09 -07:00
|
|
|
|
Add two properties to the `AppComponent`: a `title` property for the app name and a `hero` property
|
|
|
|
|
for a hero named "Windstorm."
|
2017-04-15 15:34:47 +08:00
|
|
|
|
|
2017-05-07 11:36:33 +08:00
|
|
|
|
往`AppComponent`中添加两个属性:`title`属性用来表示应用的名字,而`hero`属性用来表示名叫“Windstorm”的英雄。
|
2016-11-22 20:07:16 +08:00
|
|
|
|
|
2017-03-21 11:08:09 -07:00
|
|
|
|
+makeExample('toh-1/ts/app/app.component.1.ts', 'app-component-1', 'app.component.ts (AppComponent class)')(format=".")
|
2015-10-15 00:51:24 -07:00
|
|
|
|
|
2015-11-10 18:31:46 +00:00
|
|
|
|
:marked
|
2017-03-21 11:08:09 -07:00
|
|
|
|
Now update the template in the `@Component` decorator with data bindings to these new properties.
|
2016-11-22 20:07:16 +08:00
|
|
|
|
|
2016-12-01 15:08:04 +08:00
|
|
|
|
下面,更新`@Component`装饰器中指定的模板,为这些新属性建立数据绑定。
|
2015-10-15 00:51:24 -07:00
|
|
|
|
|
2017-03-21 11:08:09 -07:00
|
|
|
|
+makeExample('toh-1/ts/app/app.component.1.ts', 'show-hero', 'app.component.ts (@Component)')(format='.')
|
2015-12-14 20:05:13 -08:00
|
|
|
|
|
2015-11-10 18:31:46 +00:00
|
|
|
|
:marked
|
2017-03-21 11:08:09 -07:00
|
|
|
|
The browser refreshes and displays the title and hero name.
|
2017-04-15 15:34:47 +08:00
|
|
|
|
|
2016-12-01 15:08:04 +08:00
|
|
|
|
保存后,浏览器应自动刷新,显示标题和英雄。
|
2015-10-15 00:51:24 -07:00
|
|
|
|
|
2017-03-21 11:08:09 -07:00
|
|
|
|
The double curly braces are Angular's *interpolation binding* syntax.
|
|
|
|
|
These interpolation bindings present the component's `title` and `hero` property values,
|
|
|
|
|
as strings, inside the HTML header tags.
|
2017-04-15 15:34:47 +08:00
|
|
|
|
|
|
|
|
|
这里的双大括号是Angular中的*插值表达式绑定*语法。它们表示组件的`title`和`hero`属性的值会作为字符串插入到HTML标签中间。
|
2016-11-22 20:07:16 +08: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 18:04:43 -08:00
|
|
|
|
.l-sub-section
|
2015-11-14 00:22:26 -08:00
|
|
|
|
:marked
|
2017-03-21 11:08:09 -07:00
|
|
|
|
Read more about interpolation in the [Displaying Data](../guide/displaying-data.html) page.
|
2017-04-15 15:34:47 +08:00
|
|
|
|
|
2016-12-01 15:08:04 +08:00
|
|
|
|
要了解插值表达式的更多知识,见[显示数据](../guide/displaying-data.html)。
|
2016-11-22 20:07:16 +08: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 18:04:43 -08:00
|
|
|
|
:marked
|
|
|
|
|
### Hero object
|
2017-04-15 15:34:47 +08:00
|
|
|
|
|
2016-12-01 15:08:04 +08:00
|
|
|
|
### Hero 对象
|
2015-10-15 00:51:24 -07:00
|
|
|
|
|
2017-03-21 11:08:09 -07:00
|
|
|
|
The hero needs more properties.
|
|
|
|
|
Convert the `hero` from a literal string to a class.
|
2015-10-15 00:51:24 -07:00
|
|
|
|
|
2017-04-15 15:34:47 +08:00
|
|
|
|
显然,英雄还需要更多属性。
|
2016-04-12 19:07:06 +08:00
|
|
|
|
让我们把`hero`从一个字符串字面量换成一个类。
|
2016-11-22 20:07:16 +08:00
|
|
|
|
|
2016-03-24 13:31:27 +01:00
|
|
|
|
Create a `Hero` class with `id` and `name` properties.
|
2017-03-21 11:08:09 -07:00
|
|
|
|
Add these properties near the top of the `app.component.ts` file, just below the import statement.
|
2015-10-15 00:51:24 -07:00
|
|
|
|
|
2016-04-12 19:07:06 +08:00
|
|
|
|
创建一个`Hero`类,它具有`id`和`name`属性。
|
2016-12-01 15:08:04 +08:00
|
|
|
|
现在,把下列代码放在`app.component.ts`的顶部,仅次于 import 语句。
|
2016-11-22 20:07:16 +08:00
|
|
|
|
|
2017-02-02 18:38:17 +00:00
|
|
|
|
+makeExample('toh-1/ts/src/app/app.component.ts', 'hero-class-1', 'src/app/app.component.ts (Hero class)')(format=".")
|
2015-10-15 00:51:24 -07: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 18:04:43 -08:00
|
|
|
|
:marked
|
2017-04-12 04:34:15 +02:00
|
|
|
|
In the `AppComponent` class, refactor the component's `hero` property to be of type `Hero`,
|
2017-03-21 11:08:09 -07:00
|
|
|
|
then initialize it with an `id` of `1` and the name `Windstorm`.
|
2016-11-22 20:07:16 +08:00
|
|
|
|
|
2016-12-01 15:08:04 +08:00
|
|
|
|
现在,有了一个`Hero`类,我们把组件`hero`属性的类型换成`Hero`。
|
|
|
|
|
然后以`1`为 id、以 “Windstorm” 为名字,初始化它。
|
2015-10-15 00:51:24 -07:00
|
|
|
|
|
2017-02-02 18:38:17 +00:00
|
|
|
|
+makeExample('toh-1/ts/src/app/app.component.ts', 'hero-property-1', 'src/app/app.component.ts (hero property)')(format=".")
|
2015-10-15 00:51:24 -07: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 18:04:43 -08:00
|
|
|
|
:marked
|
2017-03-21 11:08:09 -07:00
|
|
|
|
Because you changed the hero from a string to an object,
|
|
|
|
|
update the binding in the template to refer to the hero's `name` property.
|
2015-10-15 00:51:24 -07:00
|
|
|
|
|
2016-05-11 19:46:09 +08:00
|
|
|
|
我们把`hero`从一个字符串换成了对象,所以也得更新模板中的绑定表达式,来引用`hero`的`name`属性。
|
2016-11-22 20:07:16 +08:00
|
|
|
|
|
2017-03-21 11:08:09 -07:00
|
|
|
|
+makeExample('toh-1/ts/app/app.component.1.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 18:04:43 -08:00
|
|
|
|
:marked
|
2017-03-21 11:08:09 -07:00
|
|
|
|
The browser refreshes and continues to display the hero's name.
|
2017-04-15 15:34:47 +08:00
|
|
|
|
|
2016-05-11 19:46:09 +08:00
|
|
|
|
浏览器自动刷新,并继续显示这位英雄的名字。
|
2015-10-15 00:51:24 -07:00
|
|
|
|
|
2017-03-21 11:08:09 -07:00
|
|
|
|
### Adding HTML with multi-line template strings
|
2017-04-15 15:34:47 +08:00
|
|
|
|
|
|
|
|
|
### 使用多行模板字符串添加更多 HTML
|
2015-10-15 00:51:24 -07:00
|
|
|
|
|
2017-03-21 11:08:09 -07:00
|
|
|
|
To show all of the hero's properties,
|
|
|
|
|
add a `<div>` for the hero's `id` property and another `<div>` for the hero's `name`.
|
|
|
|
|
To keep the template readable, place each `<div>` on its own line.
|
2017-04-15 15:34:47 +08:00
|
|
|
|
|
|
|
|
|
要显示英雄的所有属性,还要为英雄的`id`属性添加一个`<div>`,为英雄的`name`属性添加另一个`<div>`。
|
|
|
|
|
为了保持模板的可读性,把每个`<div>`单独放一行。
|
2015-10-15 00:51:24 -07:00
|
|
|
|
|
2017-03-21 11:08:09 -07:00
|
|
|
|
The backticks around the component template let you put the `<h1>`, `<h2>`, and `<div>` elements on their own lines,
|
|
|
|
|
thanks to the <i>template literals</i> feature in ES2015 and TypeScript. For more information, see
|
|
|
|
|
<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals" target="_blank" title="template literal">Template literals</a>.
|
2017-04-15 15:34:47 +08:00
|
|
|
|
|
|
|
|
|
反引号包裹的组件模板能让你把`<h1>`、`<h2>`和`<div>`元素各自放在一行上。
|
|
|
|
|
感谢ES2015和TypeScript的*模板字面量*特性。要了解更多,请参见<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals" target="_blank" title="template literal">模板字面量(Template literals)</a> 页。
|
2016-04-12 19:07:06 +08: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 18:04:43 -08:00
|
|
|
|
|
2017-03-21 11:08:09 -07:00
|
|
|
|
+makeExample('toh-1/ts/app/app.component.1.ts', 'multi-line-strings', 'app.component.ts (AppComponent\'s template)')(format='.')
|
2015-10-15 00:51:24 -07:00
|
|
|
|
|
|
|
|
|
.l-main-section
|
2015-12-14 20:05:13 -08:00
|
|
|
|
:marked
|
2017-03-21 11:08:09 -07:00
|
|
|
|
## Edit the hero name
|
2017-04-15 15:34:47 +08:00
|
|
|
|
|
|
|
|
|
## 编辑英雄名字
|
2015-10-15 00:51:24 -07:00
|
|
|
|
|
2017-03-21 11:08:09 -07:00
|
|
|
|
Users should be able to edit the hero name in an `<input>` textbox.
|
|
|
|
|
The textbox should both _display_ the hero's `name` property
|
|
|
|
|
and _update_ that property as the user types.
|
2017-04-16 21:22:10 +08:00
|
|
|
|
|
|
|
|
|
用户应该能在一个`<input>`输入框中编辑英雄的名字。
|
|
|
|
|
当用户输入时,这个输入框应该能同时*显示*和*修改*英雄的`name`属性。
|
2016-11-22 20:07:16 +08:00
|
|
|
|
|
2017-03-21 11:08:09 -07:00
|
|
|
|
You need a two-way binding between the `<input>` form element and the `hero.name` property.
|
2017-04-16 21:22:10 +08:00
|
|
|
|
|
|
|
|
|
也就是说,我们要在表单元素`<input>`和组件的`hero.name`属性之间建立双向绑定。
|
2015-10-15 00:51:24 -07:00
|
|
|
|
|
2017-03-21 11:08:09 -07:00
|
|
|
|
### Two-way binding
|
2017-04-16 21:22:10 +08: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 18:04:43 -08:00
|
|
|
|
|
2017-03-21 11:08:09 -07:00
|
|
|
|
Refactor the hero name in the template so it looks like this:
|
2017-04-16 21:22:10 +08:00
|
|
|
|
|
|
|
|
|
把模板中的英雄名字重构成这样:
|
|
|
|
|
|
2017-03-21 11:08:09 -07:00
|
|
|
|
+makeExample('toh-1/ts/app/app.component.1.ts', 'name-input')(format='.')
|
2016-06-15 23:31:28 +08:00
|
|
|
|
|
2015-12-14 20:05:13 -08:00
|
|
|
|
:marked
|
2017-03-21 11:08:09 -07:00
|
|
|
|
`[(ngModel)]` is the Angular syntax to bind the `hero.name` property
|
|
|
|
|
to the textbox.
|
2017-03-31 22:41:34 -04:00
|
|
|
|
Data flows _in both directions:_ from the property to the textbox,
|
2017-03-21 11:08:09 -07:00
|
|
|
|
and from the textbox back to the property.
|
2017-04-16 21:22:10 +08:00
|
|
|
|
|
|
|
|
|
`[(ngModel)]`是一个Angular语法,用与把`hero.name`绑定到输入框中。
|
|
|
|
|
它的数据流是*双向的*:从属性到输入框,并且从输入框回到属性。
|
2016-04-12 19:07:06 +08:00
|
|
|
|
|
2017-03-21 11:08:09 -07:00
|
|
|
|
Unfortunately, immediately after this change, the application breaks.
|
|
|
|
|
If you looked in the browser console, you'd see Angular complaining that
|
|
|
|
|
"`ngModel` ... isn't a known property of `input`."
|
2017-04-16 21:22:10 +08:00
|
|
|
|
|
|
|
|
|
不幸的是,做了这项改动之后,我们的程序崩溃了。
|
2017-05-07 11:36:33 +08:00
|
|
|
|
打开浏览器的控制台,我们会看到Angular抱怨说:“`ngModel` ... isn't a known property of `input`.”(`ngModel`不是`input`元素的已知属性)
|
2016-11-22 20:07:16 +08:00
|
|
|
|
|
2017-03-21 11:08:09 -07:00
|
|
|
|
Although `NgModel` is a valid Angular directive, it isn't available by default.
|
|
|
|
|
It belongs to the optional `FormsModule`.
|
|
|
|
|
You must opt-in to using that module.
|
2017-04-16 21:22:10 +08:00
|
|
|
|
|
|
|
|
|
虽然`NgModel`是一个有效的Angular指令,但它默认情况下却是不可用的。
|
|
|
|
|
它属于一个可选模块`FormsModule`。
|
|
|
|
|
我们必须选择使用那个模块。
|
2015-10-15 00:51:24 -07:00
|
|
|
|
|
2017-03-21 11:08:09 -07:00
|
|
|
|
### Import the _FormsModule_
|
2017-04-16 21:22:10 +08:00
|
|
|
|
|
|
|
|
|
### 导入 _FormsModule_
|
2015-10-15 00:51:24 -07:00
|
|
|
|
|
2017-03-21 11:08:09 -07:00
|
|
|
|
Open the `app.module.ts` file and import the `FormsModule` symbol from the `@angular/forms` library.
|
|
|
|
|
Then add the `FormsModule` to the `@NgModule` metadata's `imports` array, which contains the list
|
|
|
|
|
of external modules that the app uses.
|
2017-04-16 21:22:10 +08:00
|
|
|
|
|
|
|
|
|
打开`app.module.ts`文件,并且从`@angular/forms`库中导入符号`FormsModule`。
|
|
|
|
|
然后把`FormsModule`添加到`@NgModule`元数据的`imports`数组中,它是当前应用正在使用的外部模块列表。
|
2016-04-12 19:07:06 +08:00
|
|
|
|
|
2017-03-21 11:08:09 -07:00
|
|
|
|
The updated `AppModule` looks like this:
|
2017-04-16 21:22:10 +08:00
|
|
|
|
|
|
|
|
|
修改后的`AppModule`是这样的:
|
|
|
|
|
|
2017-03-21 11:08:09 -07:00
|
|
|
|
+makeExample('toh-1/ts/src/app/app.module.ts', '', 'app.module.ts (FormsModule import)')
|
2015-11-10 18:31:46 +00:00
|
|
|
|
|
2015-12-14 20:05:13 -08:00
|
|
|
|
.l-sub-section
|
2015-11-10 18:31:46 +00:00
|
|
|
|
:marked
|
2017-03-21 11:08:09 -07:00
|
|
|
|
Read more about `FormsModule` and `ngModel` in the
|
|
|
|
|
[Two-way data binding with ngModel](../guide/forms.html#ngModel) section of the
|
|
|
|
|
[Forms](../guide/forms.html) guide and the
|
|
|
|
|
[Two-way binding with NgModel](../guide/template-syntax.html#ngModel) section of the
|
|
|
|
|
[Template Syntax](../guide/template-syntax.html) guide.
|
2016-08-09 17:38:25 +01:00
|
|
|
|
|
2016-11-06 02:44:57 +08:00
|
|
|
|
要学习关于`FormsModule`和`ngModel`的更多知识,参见[表单](../guide/forms.html#ngModel)和
|
2016-12-01 15:08:04 +08:00
|
|
|
|
[模板语法](../guide/template-syntax.html#ngModel)。
|
2016-08-12 07:57:51 +08:00
|
|
|
|
|
2015-12-14 20:05:13 -08:00
|
|
|
|
:marked
|
2017-03-21 11:08:09 -07:00
|
|
|
|
When the browser refreshes, the app should work again.
|
|
|
|
|
You can edit the hero's name and see the changes reflected immediately in the `<h2>` above the textbox.
|
2015-11-10 18:31:46 +00:00
|
|
|
|
|
2016-05-11 19:46:09 +08:00
|
|
|
|
浏览器刷新。又见到我们的英雄了。我们可以编辑英雄的名字,也能看到这个改动立刻体现在`<h2>`中。
|
2016-11-22 20:07:16 +08:00
|
|
|
|
|
2015-10-16 01:06:56 -07:00
|
|
|
|
.l-main-section
|
2015-12-14 20:05:13 -08:00
|
|
|
|
:marked
|
2017-03-21 11:08:09 -07:00
|
|
|
|
## The road you've travelled
|
2017-03-31 15:25:27 -07:00
|
|
|
|
|
2016-04-12 19:07:06 +08:00
|
|
|
|
## 我们已经走过的路
|
2017-04-15 15:34:47 +08:00
|
|
|
|
|
2017-03-21 11:08:09 -07:00
|
|
|
|
Take stock of what you've built.
|
2017-04-15 15:34:47 +08:00
|
|
|
|
|
2016-05-11 19:46:09 +08:00
|
|
|
|
我们来盘点一下已经构建完成的部分。
|
2015-12-14 20:05:13 -08:00
|
|
|
|
|
2017-03-21 11:08:09 -07:00
|
|
|
|
* The Tour of Heroes app uses the double curly braces of interpolation (a type of one-way data binding)
|
|
|
|
|
to display the app title and properties of a `Hero` object.
|
2017-04-15 15:34:47 +08:00
|
|
|
|
|
2016-12-01 15:08:04 +08:00
|
|
|
|
我们的《英雄指南》使用双大括号插值表达式(单向数据绑定的一种形式)来显示应用的标题和`Hero`对象的属性。
|
2017-04-15 15:34:47 +08:00
|
|
|
|
|
2017-03-21 11:08:09 -07:00
|
|
|
|
* You wrote a multi-line template using ES2015's template literals to make the template readable.
|
2017-04-15 15:34:47 +08:00
|
|
|
|
|
2016-12-01 15:08:04 +08:00
|
|
|
|
我们使用 ES2015 的模板字符串写了一个多行模板,使我们的模板更具可读性。
|
2017-04-15 15:34:47 +08:00
|
|
|
|
|
2017-03-21 11:08:09 -07:00
|
|
|
|
* You added a two-way data binding to the `<input>` element
|
|
|
|
|
using the built-in `ngModel` directive. This binding both displays the hero's name and allows users to change it.
|
2017-04-15 15:34:47 +08:00
|
|
|
|
|
2016-12-01 15:08:04 +08:00
|
|
|
|
为了同时显示和修改英雄的名字,我们还使用了内置的`ngModel`指令,往`<input>`元素上添加了双向数据绑定。
|
2017-04-15 15:34:47 +08:00
|
|
|
|
|
2017-03-21 11:08:09 -07:00
|
|
|
|
* The `ngModel` directive propagates changes to every other binding of the `hero.name`.
|
2017-04-15 15:34:47 +08:00
|
|
|
|
|
2016-12-01 15:08:04 +08:00
|
|
|
|
`ngModel`指令将这些修改传播到每一个对`hero.name`的其它绑定。
|
2015-10-15 00:51:24 -07:00
|
|
|
|
|
2017-03-21 11:08:09 -07:00
|
|
|
|
Your app should look like this <live-example></live-example>.
|
2016-11-22 20:07:16 +08:00
|
|
|
|
|
2017-04-23 09:34:51 +08:00
|
|
|
|
运行这部分的<live-example></live-example>。
|
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 18:04:43 -08:00
|
|
|
|
|
2015-12-14 20:05:13 -08:00
|
|
|
|
Here's the complete `app.component.ts` as it stands now:
|
2016-11-22 20:07:16 +08:00
|
|
|
|
|
2016-04-12 19:07:06 +08: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 18:04:43 -08:00
|
|
|
|
|
2017-04-15 15:34:47 +08:00
|
|
|
|
+makeExample('toh-1/ts/src/app/app.component.ts', '', 'src/app/app.component.ts')
|
2015-11-10 18:31:46 +00:00
|
|
|
|
|
2015-10-16 01:06:56 -07:00
|
|
|
|
.l-main-section
|
2015-12-14 20:05:13 -08:00
|
|
|
|
:marked
|
2017-03-21 11:08:09 -07:00
|
|
|
|
## The road ahead
|
2017-04-15 15:34:47 +08:00
|
|
|
|
|
2016-04-12 19:07:06 +08:00
|
|
|
|
## 前方的路
|
2017-04-15 15:34:47 +08:00
|
|
|
|
|
2017-03-21 11:08:09 -07:00
|
|
|
|
In the [next tutorial page](./toh-pt2.html), you'll build on the Tour of Heroes app to display a list of heroes.
|
|
|
|
|
You'll also allow the user to select heroes and display their details.
|
|
|
|
|
You'll learn more about how to retrieve lists and bind them to the template.
|
2017-04-15 15:34:47 +08:00
|
|
|
|
|
|
|
|
|
在[教程的下一章](./toh-pt2.html),我们将在这个《英雄指南》中显示一个英雄列表。
|
|
|
|
|
我们将允许允许用户选择一个英雄,并且显示它/她的详情。
|
|
|
|
|
我们还将学会如何获取列表以及将它们绑定到模板中。
|