130 lines
6.0 KiB
Plaintext
Raw Normal View History

block includes
include ../_util-fns
:marked
2016-11-22 20:07:16 +08:00
Our grand plan for this tutorial is to build an app to help a staffing agency manage its stable of heroes.
2015-10-31 21:13:18 -07:00
Even heroes need to find work.
2016-11-22 20:07:16 +08:00
本教程的终极计划是构建一个程序,来帮助招聘公司管理一群英雄。
2016-11-06 01:58:39 +08:00
即使英雄们也需要找工作。
2015-10-31 21:13:18 -07:00
Of course we'll only make a little progress in this tutorial. What we do build will
have many of the features we expect to find in a full-blown, data-driven application: acquiring and displaying
a list of heroes, editing a selected hero's detail, and navigating among different
views of heroic data.
当然,在本教程中,我们只完成一小步。我们这次构建的应用会涉及很多特性:获得并显示英雄列表,编辑所选英雄的详情,并在英雄数据的多个视图之间建立导航。这些特性,在成熟的、数据驱动的应用中经常见到。
2015-10-31 21:13:18 -07:00
The Tour of Heroes covers the core fundamentals of Angular.
Well use built-in directives to show/hide elements and display lists of hero data.
Well create a component to display hero details and another to show an array of heroes.
We'll use one-way data binding for read-only data. We'll add editable fields to update a model
2016-03-07 20:14:38 -08:00
with two-way data binding. We'll bind component methods to user events like key strokes and clicks.
2015-10-31 21:13:18 -07:00
Well learn to select a hero from a master list and edit that hero in the details view. We'll
format data with pipes. We'll create a shared service to assemble our heroes. And we'll use routing to navigate among different views and their components.
这篇《英雄指南》覆盖了Angular的核心原理。
我们将使用内置指令来显示/隐藏元素,并且显示英雄数据的列表。
我们将创建一个组件来显示英雄的详情,另一个组件则用来显示英雄列表。
2016-05-11 18:58:41 +08:00
我们将对只读数据使用单向数据绑定。我们将添加一些可编辑字段,并通过双向数据绑定更新模型。
我们将把组件上的方法绑定到用户事件上,比如按键和点击。
我们将学习从主列表视图中选择一个英雄,然后在详情视图中编辑它。
我们将通过管道对数据进行格式化。
我们将创建一个共享服务来管理我们的英雄们。
我们将使用路由在不同的视图及其组件之间进行导航。
2015-10-31 21:13:18 -07:00
Well learn enough core Angular to get started and gain confidence that
Angular can do whatever we need it to do.
We'll be covering a lot of ground at an introductory level but well find plenty of links
to chapters with greater depth.
2016-11-22 20:07:16 +08:00
2016-11-06 01:53:59 +08:00
完成本教程后我们将学习足够的Angular核心技术并确信Angular确实能做到我们需要它做的。
我们将覆盖大量入门级知识,同时我们也会看到大量链接,指向更深入的章节。
Run the <live-example name="toh-6"></live-example>.
2016-11-22 20:07:16 +08:00
运行<live-example name="toh-6"></live-example>。
.l-main-section
:marked
2015-10-31 21:13:18 -07:00
## The End Game
2016-11-22 20:07:16 +08:00
2016-04-23 22:23:31 +08:00
## 游戏的终点
2015-10-12 18:36:33 -07:00
2015-10-31 21:13:18 -07:00
Here's a visual idea of where we're going in this tour, beginning with the "Dashboard"
view and our most heroic heroes:
2016-11-22 20:07:16 +08:00
下面是本教程关于界面的构想开始是“Dashboard仪表盘”视图来展示我们最勇敢的英雄。
2015-10-31 21:13:18 -07:00
figure.image-display
2016-11-22 20:07:16 +08:00
img(src='/resources/images/devguide/toh/heroes-dashboard-1.png' alt="英雄仪表盘的输出")
:marked
2015-10-31 21:13:18 -07:00
Above the dashboard are two links ("Dashboard" and "Heroes").
We could click them to navigate between this Dashboard and a Heroes view.
2015-10-12 18:36:33 -07:00
2016-11-22 20:07:16 +08:00
仪表盘顶部中有两个链接“Dashboard仪表盘”和“Heroes英雄列表”。
我们将点击它们在“仪表盘”和“英雄列表”视图之间导航。
2015-10-31 21:13:18 -07:00
Instead we click the dashboard hero named "Magneta" and the router takes us to a "Hero Details" view
of that hero where we can change the hero's name.
2016-11-22 20:07:16 +08:00
当我们点击仪表盘上名叫“Magneta”的英雄时路由将把我们带到这个英雄的详情页在这里我们可以修改英雄的名字。
2015-10-31 21:13:18 -07:00
figure.image-display
img(src='/resources/images/devguide/toh/hero-details-1.png' alt="英雄详情的输出")
:marked
Clicking the "Back" button would return us to the "Dashboard".
2015-10-31 21:13:18 -07:00
Links at the top can take us to either of the main views.
We'll click "Heroes". The app takes to the "Heroes" master list view.
2016-11-22 20:07:16 +08:00
点击“Back后退”按钮将返回到“Dashboard仪表盘”。
顶部的链接可以把我们带到任何一个主视图。
2016-11-06 01:53:59 +08:00
如果我们点击“Heroes英雄列表”链接应用将把我们带到“英雄”主列表视图。
2016-11-22 20:07:16 +08:00
2015-10-31 21:13:18 -07:00
figure.image-display
img(src='/resources/images/devguide/toh/heroes-list-2.png' alt="英雄列表的输出")
:marked
2015-10-31 21:13:18 -07:00
We click a different hero and the readonly mini-detail beneath the list reflects our new choice.
2016-11-22 20:07:16 +08:00
2016-11-06 01:53:59 +08:00
当我们点击另一位英雄时,一个只读的“微型详情视图”会显示在列表下方,以体现我们的选择。
2015-10-31 21:13:18 -07:00
We click the "View Details" button to drill into the
editable details of our selected hero.
2016-11-22 20:07:16 +08:00
2016-11-06 01:53:59 +08:00
我们可以点击“View Details查看详情”按钮进入所选英雄的编辑视图。
2015-10-31 21:13:18 -07:00
The following diagram captures all of our navigation options.
2016-11-22 20:07:16 +08:00
下面这张图汇总了我们所有可能的导航路径。
2015-10-31 21:13:18 -07:00
figure.image-display
img(src='/resources/images/devguide/toh/nav-diagram.png' alt="查看导航")
:marked
Here's our app in action
2016-11-22 20:07:16 +08:00
2016-05-11 19:25:40 +08:00
下图演示了我们应用中的所有操作。
figure.image-display
img(src='/resources/images/devguide/toh/toh-anim.gif' alt="英雄指南的所有动作")
.l-main-section
:marked
## Up Next
2016-11-22 20:07:16 +08:00
## 接下来
2015-10-31 21:13:18 -07:00
Well build this Tour of Heroes together, step by step.
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
We'll motivate each step with a requirement that we've
2015-10-31 21:13:18 -07:00
met in countless applications. Everything has a reason.
2016-11-06 01:53:59 +08:00
让我们一起一步步构建出《英雄指南》。
正如我们在无数应用遇到那样,每一步都由一个需求驱动。毕竟做任何事都要有个理由。
2015-10-31 21:13:18 -07:00
And well meet many of the core fundamentals of Angular along the way.
2016-11-22 20:07:16 +08:00
2016-05-11 19:25:40 +08:00
这一路上我们将遇到很多Angular核心原理。