diff --git a/aio/content/dict/dict-1.json b/aio/content/dict/dict-1.json index 4fd1da2823..3da37ecaf2 100644 --- a/aio/content/dict/dict-1.json +++ b/aio/content/dict/dict-1.json @@ -1,67322 +1,39667 @@ [ { - "original": "# Forms", - "translation": "# 表单", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "## Transpile", + "translation": "## 转译(transpile)", + "sourceFile": "/Users/twer/private/GDE/content-1/_fragments/glossary-t2.md" }, { - "original": "Forms are the mainstay of business applications.\nYou use forms to log in, submit a help request, place an order, book a flight,\nschedule a meeting, and perform countless other data-entry tasks.", - "translation": "表单是商业应用的支柱,我们用它来执行登录、求助、下单、预订机票、安排会议,以及不计其数的其它数据录入任务。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "The process of transforming code written in one form of JavaScript\n(such as TypeScript) into another form of JavaScript (such as [ES5](_fragments/glossary-t2#es5)).", + "translation": "把一种形式的 JavaScript(例如 TypeScript)转换成另一种形式的 JavaScript(例如 [ES5](_fragments/glossary-t2#es5))的过程。", + "sourceFile": "/Users/twer/private/GDE/content-1/_fragments/glossary-t2.md" }, { - "original": "In developing a form, it's important to create a data-entry experience that guides the\nuser efficiently and effectively through the workflow.", - "translation": "在开发表单时,创建数据方面的体验是非常重要的,它能指引用户明细、高效的完成工作流程。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "## TypeScript", + "translation": "## TypeScript 语言", + "sourceFile": "/Users/twer/private/GDE/content-1/_fragments/glossary-t2.md" }, { - "original": "Developing forms requires design skills (which are out of scope for this page), as well as framework support for\n*two-way data binding, change tracking, validation, and error handling*,\nwhich you'll learn about on this page.", - "translation": "开发表单需要设计能力(那超出了本章的范围),而框架支持*双向数据绑定、变更检测、验证和错误处理*,而本章我们会接触到它们。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "A version of JavaScript that supports most [ECMAScript 2015](_fragments/glossary-t2#es2015)\nlanguage features such as [decorators](_fragments/glossary-t2#decorator).", + "translation": "JavaScript 的一个版本,支持了几乎所有 [ECMAScript 2015](_fragments/glossary-t2#ecmascript=2015) 语言特性,例如[装饰器 (decorator)](_fragments/glossary-t2#decorator))。", + "sourceFile": "/Users/twer/private/GDE/content-1/_fragments/glossary-t2.md" }, { - "original": "This page shows you how to build a simple form from scratch. Along the way you'll learn how to:", - "translation": "这个页面演示了如何从草稿构建一个简单的表单。这个过程中你将学会如何:", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "TypeScript is also notable for its optional typing system, which provides\ncompile-time type checking and strong tooling support (such as \"intellisense,\"\ncode completion, refactoring, and intelligent search). Many code editors\nand IDEs support TypeScript either natively or with plugins.", + "translation": "TypeScript 还以它的可选类型系统而著称。\n该类型系统提供了编译时类型检查和强大的工具支持(例如 “Intellisense”,代码补齐,重构和智能搜索等)。\n许多代码编辑器和 IDE 都原生支持 TypeScript 或通过插件提供支持。", + "sourceFile": "/Users/twer/private/GDE/content-1/_fragments/glossary-t2.md" }, { - "original": "* Build an Angular form with a component and template.", - "translation": "用组件和模板构建 Angular 表单", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "TypeScript is the preferred language for Angular development, although\nyou can use other JavaScript dialects such as [ES5](_fragments/glossary-t2#es5).", + "translation": "TypeScript 是 Angular 的首选语言,当然,你可以使用其它 JavaScript 方言,例如[ES5](_fragments/glossary-t2#es5)。", + "sourceFile": "/Users/twer/private/GDE/content-1/_fragments/glossary-t2.md" }, { - "original": "* Use `ngModel` to create two-way data bindings for reading and writing input-control values.", - "translation": "用`ngModel`创建双向数据绑定,以读取和写入输入控件的值", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "Read more about TypeScript at [typescriptlang.org](http://www.typescriptlang.org/).", + "translation": "更多信息,见[typescript.org](http://www.typescriptlang.org/)。", + "sourceFile": "/Users/twer/private/GDE/content-1/_fragments/glossary-t2.md" }, { - "original": "* Track state changes and the validity of form controls.", - "translation": "跟踪状态的变化,并验证表单控件", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "# AngularJS to Angular Quick Reference", + "translation": "# 从 AngularJS 到 Angular 快速参考", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { - "original": "* Provide visual feedback using special CSS classes that track the state of the controls.", - "translation": "使用特殊的CSS类来跟踪控件的状态并给出视觉反馈", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "_Angular_ is the name for the Angular of today and tomorrow.\n_AngularJS_ is the name for all v1.x versions of Angular.", + "translation": "_Angular_ 是 Angular 现在以及未来的名字,而 _AngularJS_ 则用来专指所有 Angular 的 1.x 版本。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { - "original": "* Display validation errors to users and enable/disable form controls.", - "translation": "向用户显示验证错误提示,以及启用/禁用表单控件", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "This guide helps you transition from AngularJS to Angular\nby mapping AngularJS syntax to the equivalent Angular syntax.", + "translation": "本章提供了一个快速的参考指南,指出一些常用的AngularJS语法及其在Angular中的等价物。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { - "original": "* Share information across HTML elements using template reference variables.", - "translation": "使用模板引用变量在 HTML 元素之间共享信息", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "**See the Angular syntax in this **.", + "translation": "**参见 以学习 Angular 语法**", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { - "original": "You can run the in Plunker and download the code from there.", - "translation": "你可以在Plunker中运行,并且从那里下载代码。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "## Template basics", + "translation": "## 模板基础", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { - "original": "## Template-driven forms", - "translation": "## 模板驱动的表单", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "Templates are the user-facing part of an Angular application and are written in HTML.\nThe following table lists some of the key AngularJS template features with their equivalent Angular template syntax.", + "translation": "模板是Angular应用中的门面部分,它是用HTML写的。下表中是一些AngularJS中的关键模板特性及其在Angular中的等价语法。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { - "original": "You can build forms by writing templates in the Angular [template syntax](guide/template-syntax) with\nthe form-specific directives and techniques described in this page.", - "translation": "通常,使用 Angular [模板语法](guide/template-syntax)编写模板,结合本章所描述的表单专用指令和技术来构建表单。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "### Bindings/interpolation", + "translation": "### 绑定/插值表达式", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { - "original": "You can also use a reactive (or model-driven) approach to build forms.\nHowever, this page focuses on template-driven forms.", - "translation": "你还可以使用响应式(也叫模型驱动)的方式来构建表单。不过本章中只介绍模板驱动表单。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "In AngularJS, an expression in curly braces denotes one-way binding.\n This binds the value of the element to a property in the controller\n associated with this template.", + "translation": "在AngularJS中,花括号中的表达式代表单向绑定。\n 它把元素的值绑定到了与模板相关控制器的属性上。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { - "original": "You can build almost any form with an Angular template—login forms, contact forms, and pretty much any business form.\nYou can lay out the controls creatively, bind them to data, specify validation rules and display validation errors,\nconditionally enable or disable specific controls, trigger built-in visual feedback, and much more.", - "translation": "利用 Angular 模板,可以构建几乎所有表单 — 登录表单、联系人表单…… 以及任何的商务表单。\n 可以创造性的摆放各种控件、把它们绑定到数据、指定校验规则、显示校验错误、有条件的禁用或\n 启用特定的控件、触发内置的视觉反馈等等,不胜枚举。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "When using the `controller as` syntax,\n the binding is prefixed with the controller alias (`vm` or `$ctrl`) because you\n have to be specific about the source of the binding.", + "translation": "当使用`controller as`语法时,该绑定需要用控制器的别名(`vm`)为前缀,这是因为我们不得不通过它来指定绑定源。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { - "original": "Angular makes the process easy by handling many of the repetitive, boilerplate tasks you'd\notherwise wrestle with yourself.", - "translation": "它用起来很简单,这是因为 Angular 处理了大多数重复、单调的任务,这让我们可以不必亲自操刀、身陷其中。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "### Bindings/interpolation", + "translation": "### 绑定/插值表达式", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { - "original": "You'll learn to build a template-driven form that looks like this:", - "translation": "我们将学习构建如下的“模板驱动”表单:", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "In Angular, a template expression in curly braces still denotes one-way binding.\n This binds the value of the element to a property of the component.\n The context of the binding is implied and is always the\n associated component, so it needs no reference variable.", + "translation": "在Angular中,花括号中的模板表达式同样代表单向绑定。\n 它把元素的值绑定到了组件的属性上。\n 它绑定的上下文变量是隐式的,并且总是关联到组件。\n 所以,它不需要一个引用变量。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { - "original": "The *Hero Employment Agency* uses this form to maintain personal information about heroes.\nEvery hero needs a job. It's the company mission to match the right hero with the right crisis.", - "translation": "这里是*英雄职业介绍所*,使用这个表单来维护候选英雄们的个人信息。每个英雄都需要一份工作。\n公司的使命就是让合适的英雄去应对恰当的危机!", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "For more information, see the [Interpolation](guide/template-syntax#interpolation)\n section of the [Template Syntax](guide/template-syntax) page.", + "translation": "要了解更多,请参见[模板语法](guide/template-syntax)中的[插值表达式](guide/template-syntax#interpolation)部分。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { - "original": "Two of the three fields on this form are required. Required fields have a green bar on the left to make them easy to spot.", - "translation": "表单中的三个字段,其中两个是必填的。必填的字段在左侧有个绿色的竖条,方便用户分辨哪些是必填项。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "### Filters", + "translation": "### 过滤器", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { - "original": "If you delete the hero name, the form displays a validation error in an attention-grabbing style:", - "translation": "如果删除了英雄的名字,表单就会用醒目的样式把验证错误显示出来。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "To filter output in AngularJS templates, use the pipe character (|) and one or more filters.", + "translation": "要在AngularJS中过滤输出,使用管道字符(|)以及一个或多个过滤器。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { - "original": "如果删除了英雄的名字,表单就会用醒目的样式把验证错误显示出来。", - "translation": "
\n \"无效!名字是必填项\"\n
", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "This example filters the `title` property to uppercase.", + "translation": "在这个例子中,我们把`title`属性过滤成了大写形式。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { - "original": "Note that the *Submit* button is disabled, and the \"required\" bar to the left of the input control changes from green to red.", - "translation": "注意,提交按钮被禁用了,而且输入控件左侧的“必填”条从绿色变为了红色。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "### Pipes", + "translation": "### 管道", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { - "original": "You can customize the colors and location of the \"required\" bar with standard CSS.", - "translation": "稍后,会使用标准 CSS 来定制“必填”条的颜色和位置。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "In Angular you use similar syntax with the pipe (|) character to filter output, but now you call them **pipes**.\n Many (but not all) of the built-in filters from AngularJS are\n built-in pipes in Angular.", + "translation": "在Angular中,我们使用相似的语法 —— 用管道字符(|)来过滤输出,但是现在直接把它叫做**管道**了。\n 很多(但不是所有)AngularJS中的内置过滤器也成了Angular中的内置管道。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { - "original": "You'll build this form in small steps:", - "translation": "我们将一点点构建出此表单:", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "For more information, see [Filters/pipes](guide/ajs-quick-reference#filters-pipes) below.", + "translation": "请参见下面[过滤器/管道](guide/ajs-quick-reference#filters-pipes)了解更多信息。\n ", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { - "original": "1. Create the `Hero` model class.", - "translation": "创建`Hero`模型类", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "### Local variables", + "translation": "### 局部变量", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { - "original": "1. Create the component that controls the form.", - "translation": "创建控制此表单的组件。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "Here, `movie` is a user-defined local variable.", + "translation": "这里的`movie`是一个用户定义的局部变量", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { - "original": "1. Create a template with the initial form layout.", - "translation": "创建具有初始表单布局的模板。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "### Input variables", + "translation": "### 输入变量", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { - "original": "1. Bind data properties to each form control using the `ngModel` two-way data-binding syntax.", - "translation": "使用`ngModel`双向数据绑定语法把数据属性绑定到每个表单输入控件。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "Angular has true template input variables that are explicitly defined using the `let` keyword.", + "translation": "在Angular中,我们有了真正的模板输入变量,它需要使用`let`关键字进行明确定义。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { - "original": "1. Add a `name` attribute to each form-input control.", - "translation": "往每个表单输入控件上添加`name`属性 (attribute)。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "For more information, see the [ngFor micro-syntax](guide/template-syntax#microsyntax)\n section of the [Template Syntax](guide/template-syntax) page.", + "translation": "要了解更多信息,请参见[模板语法](guide/template-syntax)中的[ngFor微语法](guide/template-syntax#microsyntax)部分。\n ", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { - "original": "1. Add custom CSS to provide visual feedback.", - "translation": "添加自定义 CSS 来提供视觉反馈。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "## Template directives", + "translation": "## 模板指令", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { - "original": "1. Show and hide validation-error messages.", - "translation": "显示和隐藏有效性验证的错误信息。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "AngularJS provides more than seventy built-in directives for templates.\nMany of them aren't needed in Angular because of its more capable and expressive binding system.\nThe following are some of the key AngularJS built-in directives and their equivalents in Angular.", + "translation": "AngularJS 为模板提供了七十多个内置指令。\n在 Angular 中,它们很多都已经不需要了,因为 Angular 有了一个更加强大、快捷的绑定系统。\n下面是一些AngularJS 中的关键指令及其在 Angular 中的等价物。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { - "original": "1. Handle form submission with *ngSubmit*.", - "translation": "使用 **ngSubmit** 处理表单提交。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "The application startup process is called **bootstrapping**.", + "translation": "应用的启动过程被称为**引导**。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { - "original": "1. Disable the form’s *Submit* button until the form is valid.", - "translation": "禁用此表单的提交按钮,直到表单变为有效。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "Although you can bootstrap an AngularJS app in code,\n many applications bootstrap declaratively with the `ng-app` directive,\n giving it the name of the application's module (`movieHunter`).", + "translation": "虽然可以从代码中引导Angular应用,\n 但很多应用都是通过`ng-app`指令进行声明式引导的,只要给它一个应用模块的名字(`movieHunter`)就可以了。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { - "original": "## Setup", - "translation": "## 搭建", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "### Bootstrapping", + "translation": "### 引导", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { - "original": "Follow the [setup](guide/setup) instructions for creating a new project\nnamed angular-forms.", - "translation": "按照[搭建本地开发环境](guide/setup)的说明,创建一个名为angular-forms的新项目。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "Angular doesn't have a bootstrap directive.\n To launch the app in code, explicitly bootstrap the application's root module (`AppModule`)\n in `main.ts`\n and the application's root component (`AppComponent`) in `app.module.ts`.", + "translation": "Angular 没有引导指令。\n 我们总是通过显式调用一个`bootstrap`函数,并传入应用模块的名字(`AppComponent`)来启动应用。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { - "original": "## Create the Hero model class", - "translation": "## 创建 Hero 模型类", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "For more information see the [Setup](guide/setup) page.", + "translation": "要了解更多,参见[搭建本地开发环境](guide/setup)。\n ", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { - "original": "As users enter form data, you'll capture their changes and update an instance of a model.\nYou can't lay out the form until you know what the model looks like.", - "translation": "当用户输入表单数据时,需要捕获它们的变化,并更新到模型的实例中。\n除非知道模型里有什么,否则无法设计表单的布局。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "In AngularJS, the `ng-class` directive includes/excludes CSS classes\n based on an expression. That expression is often a key-value control object with each\n key of the object defined as a CSS class name, and each value defined as a template expression\n that evaluates to a Boolean value.", + "translation": "在AngularJS中,`ng-class`指令会基于一个表达式来包含/排除某些CSS类。该表达式通常是一个“键-值”型的控制对象,\n 对象中的每一个键代表一个CSS类名,每一个值定义为一个返回布尔值的模板表达式。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { - "original": "A model can be as simple as a \"property bag\" that holds facts about a thing of application importance.\nThat describes well the `Hero` class with its three required fields (`id`, `name`, `power`)\nand one optional field (`alterEgo`).", - "translation": "最简单的模型是个“属性包”,用来存放应用中一件事物的事实。\n这里使用三个必备字段 (`id`、`name`、`power`),和一个可选字段 (`alterEgo`,译注:中文含义是第二人格,例如 X 战警中的 Jean / 黑凤凰)。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "In the first example, the `active` class is applied to the element if `isActive` is true.", + "translation": "在第一个例子中,当`isActive`为真时,`active`类会被应用到元素上。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { - "original": "In the `app` directory, create the following file with the given content:", - "translation": "在应用文件夹中创建下列文件:", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "You can specify multiple classes, as shown in the second example.", + "translation": "就像第二个例子中展示的,可以指定多个CSS类。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { - "original": "It's an anemic model with few requirements and no behavior. Perfect for the demo.", - "translation": "这是一个少量需求和零行为的贫血模型。对演示来说很完美。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "In Angular, the `ngClass` directive works similarly.\n It includes/excludes CSS classes based on an expression.", + "translation": "在Angular中,`ngClass`指令用类似的方式工作。\n 它根据一个表达式包含/排除某些CSS类。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { - "original": "The TypeScript compiler generates a public field for each `public` constructor parameter and\nautomatically assigns the parameter’s value to that field when you create heroes.", - "translation": "TypeScript 编译器为每个`public`构造函数参数生成一个公共字段,在创建新的英雄实例时,自动把参数值赋给这些公共字段。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "In the first example, the `active` class is applied to the element if `isActive` is true.", + "translation": "在第一个例子中,如果`isActive`为真,则`active`类被应用到那个元素上。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { - "original": "The `alterEgo` is optional, so the constructor lets you omit it; note the question mark (?) in `alterEgo?`.", - "translation": "`alterEgo`是可选的,调用构造函数时可省略,注意`alterEgo?`中的问号 (?)。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "You can specify multiple classes, as shown in the second example.", + "translation": "就像第二个例子中所展示的那样,可以同时指定多个类。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { - "original": "You can create a new hero like this:", - "translation": "可以这样创建新英雄:", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "Angular also has **class binding**, which is a good way to add or remove a single class,\n as shown in the third example.", + "translation": "Angular还有**类绑定**,它是单独添加或移除一个类的好办法 —— 就像第三个例子中展示的。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { - "original": "## Create a form component", - "translation": "## 创建表单组件", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "For more information see the [Attribute, class, and style bindings](guide/template-syntax#other-bindings) \n section of the [Template Syntax](guide/template-syntax) page.", + "translation": "要了解更多信息,参见[模板语法](guide/template-syntax)中的[属性、CSS类和样式绑定](guide/template-syntax#other-bindings)部分。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { - "original": "An Angular form has two parts: an HTML-based _template_ and a component _class_\nto handle data and user interactions programmatically.\nBegin with the class because it states, in brief, what the hero editor can do.", - "translation": "Angular 表单分为两部分:基于 HTML 的*模板*和组件*类*,用来程序处理数据和用户交互。\n先从组件类开始,是因为它可以简要说明英雄编辑器能做什么。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "In AngularJS, the `ng-click` directive allows you to specify custom behavior when an element is clicked.", + "translation": "在AngularJS中,`ng-click`指令指定当元素被点击时的自定义行为。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { - "original": "Create the following file with the given content:", - "translation": "创建下列文件:", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "In the first example, when the user clicks the button, the `toggleImage()` method in the controller referenced by the `vm` `controller as` alias is executed.", + "translation": "在第一个例子中,如果用户点击了这个按钮,那么控制器的`toggleImage()`方法就会被执行,这个控制器是被`controller as`中指定的`vm`别名所引用的。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { - "original": "There’s nothing special about this component, nothing form-specific,\nnothing to distinguish it from any component you've written before.", - "translation": "这个组件没有什么特别的地方,没有表单相关的东西,与之前写过的组件没什么不同。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "The second example demonstrates passing in the `$event` object, which provides details about the event\n to the controller.", + "translation": "第二个例子演示了传入`$event`对象,它提供了事件的详情,并被传到控制器。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { - "original": "Understanding this component requires only the Angular concepts covered in previous pages.", - "translation": "只需要前面章节中学过的概念,就可以完全理解这个组件:", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "### Bind to the `click` event", + "translation": "### 绑定到`click`事件", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { - "original": "* The code imports the Angular core library and the `Hero` model you just created.", - "translation": "这段代码导入了Angular核心库以及我们刚刚创建的`Hero`模型。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "AngularJS event-based directives do not exist in Angular.\n Rather, define one-way binding from the template view to the component using **event binding**.", + "translation": "AngularJS基于事件的指令在Angular中已经不存在了。\n 不过,可以使用**事件绑定**来定义从模板视图到组件的单向数据绑定。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { - "original": "* The `@Component` selector value of \"hero-form\" means you can drop this form in a parent template with a `` tag.", - "translation": "`@Component`选择器“hero-form”表示可以用``标签把这个表单放进父模板。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "For event binding, define the name of the target event within parenthesis and\n specify a template statement, in quotes, to the right of the equals. Angular then\n sets up an event handler for the target event. When the event is raised, the handler\n executes the template statement.", + "translation": "要使用事件绑定,把目标事件的名字放在圆括号中,并且使用等号右侧引号中的模板语句对它赋值。\n 然后Angular为这个目标时间设置事件处理器。当事件被触发时,这个处理器就会执行模板语句。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { - "original": "* The `templateUrl` property points to a separate file for the template HTML.", - "translation": "`moduleId: module.id`属性设置了基地址,用于从相对模块路径加载`templateUrl`。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "In the first example, when a user clicks the button, the `toggleImage()` method in the associated component is executed.", + "translation": "在第一个例子中,当用户点击此按钮时,相关组件中的`toggleImage()`方法就被执行了。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { - "original": "* You defined dummy data for `model` and `powers`, as befits a demo.", - "translation": "`templateUrl`属性指向一个独立的 HTML 模板文件。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "The second example demonstrates passing in the `$event` object, which provides details about the event\n to the component.", + "translation": "第二个例子演示了如何传入`$event`对象,它为组件提供了此事件的详情。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { - "original": "Down the road, you can inject a data service to get and save real data\nor perhaps expose these properties as inputs and outputs\n(see [Input and output properties](guide/template-syntax#inputs-outputs) on the\n[Template Syntax](guide/template-syntax) page) for binding to a\nparent component. This is not a concern now and these future changes won't affect the form.", - "translation": "接下来,我们可以注入一个数据服务,以获取或保存真实的数据,或者把这些属性暴露为输入属性和输出属性(参见[Template Syntax](guide/template-syntax)中的[输入和输出属性](guide/template-syntax#inputs-outputs))来绑定到一个父组件。这不是现在需要关心的问题,未来的更改不会影响到这个表单。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "For a list of DOM events, see: https://developer.mozilla.org/en-US/docs/Web/Events.", + "translation": "要查看DOM事件的列表,请参见[网络事件](https://developer.mozilla.org/en-US/docs/Web/Events)。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { - "original": "* You added a `diagnostic` property to return a JSON representation of the model.\nIt'll help you see what you're doing during development; you've left yourself a cleanup note to discard it later.", - "translation": "我们添加一个`diagnostic`属性,以返回这个模型的 JSON 形式。在开发过程中,它用于调试,最后清理时会丢弃它。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "For more information, see the [Event binding](guide/template-syntax#event-binding) \n section of the [Template Syntax](guide/template-syntax) page.", + "translation": "要了解更多,请参见[模板语法](guide/template-syntax)中的[事件绑定](guide/template-syntax#event-binding)部分。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { - "original": "### Why the separate template file?", - "translation": "### 为何分离模板文件?", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "In AngularJS, the `ng-controller` directive attaches a controller to the view.\n Using the `ng-controller` (or defining the controller as part of the routing) ties the\n view to the controller code associated with that view.", + "translation": "在AngularJS中,`ng-controller`指令把控制器附加到视图上。\n 使用`ng-controller`(或把控制器定义为路由的一部分)把视图及其控制器的代码联系在一起。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { - "original": "Why don't you write the template inline in the component file as you often do elsewhere?", - "translation": "为什么不与我们在其他地方常常做的那样,以内联的方式把模板写在组件文件中呢?", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "### Component decorator", + "translation": "### Component装饰器", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { - "original": "There is no \"right\" answer for all occasions. Inline templates are useful when they are short.\nMost form templates aren't short. TypeScript and JavaScript files generally aren't the best place to\nwrite (or read) large stretches of HTML, and few editors help with files that have a mix of HTML and code.", - "translation": "没有什么答案在所有场合都总是“正确”的。当模板足够短的时候,内联形式更招人喜欢。\n但大多数的表单模板都不短。通常,TypeScript 和 JavaScript 文件不是写(读)大型 HTML 的好地方,\n而且没有几个编辑器能对混写的 HTML 和代码提供足够的帮助。\n我们还是喜欢内容清晰、目标明确的短文件,像这个一样。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "In Angular, the template no longer specifies its associated controller.\n Rather, the component specifies its associated template as part of the component class decorator.", + "translation": "在Angular中,模板不用再指定它相关的控制器。\n 反过来,组件会在组件类的装饰器中指定与它相关的模板。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { - "original": "Form templates tend to be large, even when displaying a small number of fields,\nso it's usually best to put the HTML template in a separate file.\nYou'll write that template file in a moment. First,\nrevise the `app.module.ts` and `app.component.ts` to make use of the new `HeroFormComponent`.", - "translation": "就算是在仅仅显示少数表单项目时,表单模板一般都比较庞大。所以通常最好的方式是将 HTML 模板放到单独的文件中。\n一会儿将编写这个模板文件。在这之前,先退一步,再看看`app.module.ts`和`app.component.ts`,让它们使用新的`HeroFormComponent`。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "For more information, see [Architecture Overview](guide/architecture#components).", + "translation": "要了解更多,请参见[架构概览](guide/architecture#components)。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { - "original": "## Revise *app.module.ts*", - "translation": "## 修改 *app.module.ts*", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "### ng-hide\n In AngularJS, the `ng-hide` directive shows or hides the associated HTML element based on\n an expression. For more information, see [ng-show](guide/ajs-quick-reference#ng-show).", + "translation": "在AngularJS中,`ng-hide`指令会基于一个表达式显示或隐藏相关的HTML元素。\n 参见[ng-show](guide/ajs-quick-reference#ng-show)了解更多。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { - "original": "`app.module.ts` defines the application's root module. In it you identify the external modules you'll use in the application\nand declare the components that belong to this module, such as the `HeroFormComponent`.", - "translation": "`app.module.ts`定义了应用的根模块。其中标识即将用到的外部模块,以及声明属于本模块中的组件,例如`HeroFormComponent`。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "### Bind to the `hidden` property", + "translation": "### 绑定`hidden`属性", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { - "original": "Because template-driven forms are in their own module, you need to add the `FormsModule` to the array of\n`imports` for the application module before you can use forms.", - "translation": "因为模板驱动的表单位于它们自己的模块,所以在使用表单之前,需要将`FormsModule`添加到应用模块的`imports`数组中。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "In Angular, you use property binding; there is no built-in *hide* directive.\n For more information, see [ng-show](guide/ajs-quick-reference#ng-show).", + "translation": "在Angular中,并没有一个内置的*hide*指令,可以改用属性绑定。\n 参见[ng-show](guide/ajs-quick-reference#ng-show)了解更多。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { - "original": "Replace the contents of the \"QuickStart\" version with the following:", - "translation": "把“快速上手”版的文件替换为如下内容:", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "The `ng-href` directive allows AngularJS to preprocess the `href` property so that it\n can replace the binding expression with the appropriate URL before the browser\n fetches from that URL.", + "translation": "`ng-href`指令允许AngularJS对`href`属性进行预处理,以便它能在浏览器获取那个URL之前,使用一个返回适当URL的绑定表达式替换它。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { - "original": "There are three changes:", - "translation": "有三处更改:", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "In AngularJS, the `ng-href` is often used to activate a route as part of navigation.", + "translation": "在AngularJS 中,`ng-href`通常用来作为导航的一部分,激活一个路由。\n \n <a ng-href=\"#movies\">Movies</a>\n ", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { - "original": "1. You import `FormsModule` and the new `HeroFormComponent`.", - "translation": "导入`FormsModule`和新组件`HeroFormComponent`。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "Routing is handled differently in Angular.", + "translation": "路由在Angular中的处理方式不同。\n ", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { - "original": "1. You add the `FormsModule` to the list of `imports` defined in the `@NgModule` decorator. This gives the application\naccess to all of the template-driven forms features, including `ngModel`.", - "translation": "把`FormsModule`添加到`ngModule`装饰器的`imports`列表中,这样应用就能访问模板驱动表单的所有特性,包括`ngModel`。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "### Bind to the `href` property", + "translation": "### 绑定到`href`属性", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { - "original": "1. You add the `HeroFormComponent` to the list of `declarations` defined in the `@NgModule` decorator. This makes\nthe `HeroFormComponent` component visible throughout this module.", - "translation": "把`HeroFormComponent`添加到`ngModule`装饰器的`declarations`列表中,使`HeroFormComponent`组件在整个模块中可见。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "Angular uses property binding; there is no built-in *href* directive.\n Place the element's `href` property in square brackets and set it to a quoted template expression.", + "translation": "在Angular中,并没有内置的*href*指令,改用属性绑定。\n 我们把元素的`href`属性放在方括号中,并把它设成一个引号中的模板表达式。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { - "original": "If a component, directive, or pipe belongs to a module in the `imports` array, ​_don't_​ re-declare it in the `declarations` array.\nIf you wrote it and it should belong to this module, ​_do_​ declare it in the `declarations` array.", - "translation": "如果某个组件、指令或管道是属于`imports`中所导入的某个模块的,那就_不能再_把它再声明到本模块的`declarations`数组中。\n如果它是你自己写的,并且确实属于当前模块,*才应该*把它声明在`declarations`数组中。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "For more information see the [Property binding](guide/template-syntax#property-binding) \n section of the [Template Syntax](guide/template-syntax) page.", + "translation": "要了解[属性绑定](guide/template-syntax#property-binding)的更多知识,参见[模板语法](guide/template-syntax)。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { - "original": "## Revise *app.component.ts*", - "translation": "## 修改 *app.component.ts*", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "In Angular, `href` is no longer used for routing. Routing uses `routerLink`, as shown in the following example.", + "translation": "在Angular中,`href`不再用作路由,而是改用第三个例子中所展示的`routerLink`指令。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { - "original": "`AppComponent` is the application's root component. It will host the new `HeroFormComponent`.", - "translation": "`AppComponent`是应用的根组件,`HeroFormComponent`将被放在其中。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "For more information on routing, see the [RouterLink binding](guide/router#router-link) \n section of the [Routing & Navigation](guide/router) page.", + "translation": "要了解关于路由的更多信息,请参见[路由与导航](guide/router)的[RouterLink绑定](guide/router#router-link)部分。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { - "original": "Replace the contents of the \"QuickStart\" version with the following:", - "translation": "把“快速上手”的版本内容替换成下列代码:", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "In AngularJS, the `ng-if` directive removes or recreates a portion of the DOM,\n based on an expression. If the expression is false, the element is removed from the DOM.", + "translation": "在AngularJS中,`ng-if`指令会根据一个表达式来移除或重建DOM中的一部分。如果表达式为假,元素就会被从DOM中移除。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { - "original": "There are only two changes.\nThe `template` is simply the new element tag identified by the component's `selector` property.\nThis displays the hero form when the application component is loaded.\nYou've also dropped the `name` field from the class body.", - "translation": "这里只做了两处修改。\n`template`中只剩下这个新的元素标签,即组件的`selector`属性。这样当应用组件被加载时,就会显示这个英雄表单。\n另外,我们还从类中移除了`name`字段。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "In this example, the `` element is removed from the DOM unless the `movies` array has a length greater than zero.", + "translation": "在这个例子中,除非`movies`数组的长度大于0,否则`
`元素就会被从DOM中移除。\n ", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { - "original": "## Create an initial HTML form template", - "translation": "## 创建初始 HTML 表单模板", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "The `*ngIf` directive in Angular works the same as the `ng-if` directive in AngularJS. It removes \n or recreates a portion of the DOM based on an expression.", + "translation": "Angular中的`*ngIf`指令与AngularJS中的`ng-if`指令一样,\n 它根据表达式的值移除或重建DOM中的一部分。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { - "original": "Create the template file with the following contents:", - "translation": "用下列内容新建模板文件:", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "In this example, the `
` element is removed from the DOM unless the `movies` array has a length.", + "translation": "在这个例子中,除非`movies`数组的长度大于0,否则`
`元素就会被从DOM中移除。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { - "original": "The language is simply HTML5. You're presenting two of the `Hero` fields, `name` and `alterEgo`, and\nopening them up for user input in input boxes.", - "translation": "这只是一段普通的旧式 HTML 5 代码。这里有两个`Hero`字段,`name`和`alterEgo`,供用户输入。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "The (*) before `ngIf` is required in this example.\n For more information, see [Structural Directives](guide/structural-directives).", + "translation": "在这个例子中`ngIf`前的星号(*)是必须的。\n 要了解更多信息,参见[结构型指令](guide/structural-directives)。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { - "original": "The *Name* `` control has the HTML5 `required` attribute;\nthe *Alter Ego* `` control does not because `alterEgo` is optional.", - "translation": "*Name* ``控件具有 HTML5 的`required`属性;但 *Alter Ego* ``控件没有,因为`alterEgo`字段是可选的。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "In AngularJS, the `ng-model` directive binds a form control to a property in the controller associated with the template.\n This provides **two-way binding**, whereby any change made to the value in the view is synchronized with the model, and any change to the model is synchronized with the value in the view.", + "translation": "在Angular1中,`ng-model`指令把一个表单控件绑定到了模板相关控制器的一个属性上。\n 这提供了**双向绑定**功能,因此,任何对视图中值的改动,都会同步到模型中,对模型的改动,也会同步到视图中。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { - "original": "You added a *Submit* button at the bottom with some classes on it for styling.", - "translation": "在底部添加个 *Submit* 按钮,它还带一些 CSS 样式类。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "In Angular, **two-way binding** is denoted by `[()]`, descriptively referred to as a \"banana in a box\". This syntax is a shortcut for defining both property binding (from the component to the view)\n and event binding (from the view to the component), thereby providing two-way binding.", + "translation": "在Angular中,**双向绑定**使用[()]标记出来,它被形象的比作“盒子中的香蕉”。\n 这种语法是一个简写形式,用来同时定义一个属性绑定(从组件到视图)和一个事件绑定(从视图到组件),因此,我们得到了双向绑定。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { - "original": "*You're not using Angular yet*. There are no bindings or extra directives, just layout.", - "translation": "**我们还没有真正用到Angular**。没有绑定,没有额外的指令,只有布局。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "For more information on two-way binding with `ngModel`, see the [NgModel—Two-way binding to \n form elements with `[(ngModel)]`](../guide/template-syntax.html#ngModel) \n section of the [Template Syntax](guide/template-syntax) page.", + "translation": "要了解使用ngModel进行双向绑定的更多知识,参见[模板语法](guide/template-syntax)中的[NgModel—使用`[(ngModel)]`进行双向绑定](../guide/template-syntax.html#ngModel)部分。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { - "original": "In template driven forms, if you've imported `FormsModule`, you don't have to do anything\nto the `` tag in order to make use of `FormsModule`. Continue on to see how this works.", - "translation": "在模板驱动表单中,你只要导入了`FormsModule`就不用对``做任何改动来使用`FormsModule`。接下来你会看到它的原理。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "In AngularJS, the `ng-repeat` directive repeats the associated DOM element\n for each item in the specified collection.", + "translation": "在Angular1中,`ng-repeat`指令会为指定集合中的每一个条目重复渲染相关的DOM元素。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { - "original": "The `container`, `form-group`, `form-control`, and `btn` classes\ncome from [Twitter Bootstrap](http://getbootstrap.com/css/). These classes are purely cosmetic.\nBootstrap gives the form a little style.", - "translation": "`container`、`form-group`、`form-control`和`btn`类来自 [Twitter Bootstrap](http://getbootstrap.com/css/)。纯粹是装饰。\n我们使用 Bootstrap 来美化表单。嘿,一点样式都没有的表单算个啥!", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "In this example, the table row (``) element repeats for each movie object in the collection of movies.", + "translation": "在这个例子中,对`movies`集合中的每一个`movie`对象重复渲染了这个表格行元素(``)。\n ", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { - "original": "
\n Angular forms don't require a style library\n
", - "translation": "
\n Angular 表单不需要任何样式库\n
", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "The `*ngFor` directive in Angular is similar to the `ng-repeat` directive in AngularJS. It repeats \n the associated DOM element for each item in the specified collection.\n More accurately, it turns the defined element (`` in this example) and its contents into a template and\n uses that template to instantiate a view for each item in the list.", + "translation": "Angular中的`*ngFor`指令类似于AngularJS中的`ng-repeat`指令。\n 它为指定集合中的每一个条目重复渲染了相关的DOM元素。\n 更准确的说,它把被界定出来的元素(这个例子中是``)及其内容转成了一个模板,并使用那个模板来为列表中的每一个条目实例化一个视图。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { - "original": "Angular makes no use of the `container`, `form-group`, `form-control`, and `btn` classes or\nthe styles of any external library. Angular apps can use any CSS library or none at all.", - "translation": "Angular 不需要`container`、`form-group`、`form-control`和`btn`类,\n或者外部库的任何样式。Angular 应用可以使用任何 CSS 库…… ,或者啥都不用。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "Notice the other syntax differences:\n The (*) before `ngFor` is required;\n the `let` keyword identifies `movie` as an input variable;\n the list preposition is `of`, not `in`.", + "translation": "请注意其它语法上的差异:\n 在`ngFor`前面的星号(*)是必须的;`let`关键字把`movie`标记成一个输入变量;列表中使用的介词是`of`,而不再是`in`。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { - "original": "To add the stylesheet, open `index.html` and add the following link to the ``:", - "translation": "我们来添加样式表。打开`index.html`,并把下列链接添加到``中:", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "For more information, see [Structural Directives](guide/structural-directives).", + "translation": "要了解更多信息,参见[结构性指令](guide/structural-directives)。\n ", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { - "original": "## Add powers with _*ngFor_", - "translation": "## 用 ***ngFor*** 添加超能力", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "In AngularJS, the `ng-show` directive shows or hides the associated DOM element, based on\n an expression.", + "translation": "在AngularJS中,`ng-show`指令根据一个表达式来显示或隐藏相关的DOM元素。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { - "original": "The hero must choose one superpower from a fixed list of agency-approved powers.\nYou maintain that list internally (in `HeroFormComponent`).", - "translation": "我们的英雄必须从认证过的固定列表中选择一项超能力。\n 这个列表位于`HeroFormComponent`中。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "In this example, the `
` element is shown if the `favoriteHero` variable is truthy.", + "translation": "在这个例子中,如果`favoriteHero`变量为真,`
`元素就会显示出来。\n ", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { - "original": "You'll add a `select` to the\nform and bind the options to the `powers` list using `ngFor`,\na technique seen previously in the [Displaying Data](guide/displaying-data) page.", - "translation": "在表单中添加`select`,用`ngFor`把`powers`列表绑定到列表选项。\n我们在之前的[显示数据](guide/displaying-data)一章中见过`ngFor`。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "### Bind to the `hidden` property", + "translation": "### 绑定到`hidden`属性", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { - "original": "Add the following HTML *immediately below* the *Alter Ego* group:", - "translation": "在 *Alter Ego* 的紧下方添加如下 HTML:", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "Angular uses property binding; there is no built-in *show* directive.\n For hiding and showing elements, bind to the HTML `hidden` property.", + "translation": "在Angular中,并没有内置的*show*指令,可以改用属性绑定。\n 要隐藏或显示一个元素,绑定到它的`hidden`属性就可以了。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { - "original": "This code repeats the `
", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { - "original": "The *NgModel* directive doesn't just track state; it updates the control with special Angular CSS classes that reflect the state.\nYou can leverage those class names to change the appearance of the control.", - "translation": "*NgModel* 指令不仅仅跟踪状态。它还使用特定的 Angular CSS 类来更新控件,以反映当前状态。\n可以利用这些 CSS 类来修改控件的外观,显示或隐藏消息。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "Selects up to the first parameter (2) number of items from the collection\n starting (optionally) at the beginning index (0).", + "translation": "从集合中选择从(第二参数指定的)起始索引号(0)开始的最多(第一参数指定的)条目数(2)个条目。\n ", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { - "original": "

\n State\n

", - "translation": "

\n 状态\n

", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "The `SlicePipe` does the same thing but the *order of the parameters is reversed*, in keeping\n with the JavaScript `Slice` method.\n The first parameter is the starting index; the second is the limit.\n As in AngularJS, coding this operation within the component instead could improve performance.", + "translation": "`SlicePipe`做同样的事,但是*两个参数的顺序是相反的*,以便于JavaScript中的`slice`方法保持一致。\n 第一个参数是起始索引号,第二个参数是限制的数量。\n 和AngularJS中一样,如果们改用组件中的代码实现此操作,性能将会提升。\n ", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { - "original": "

\n Class if true\n

", - "translation": "

\n 为真时的 CSS 类\n

", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "Converts the string to lowercase.", + "translation": "把该字符串转成小写形式。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { - "original": "

\n Class if false\n

", - "translation": "

\n 为假时的 CSS 类\n

", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "The Angular `lowercase` pipe does the same thing.", + "translation": "Angular的`lowercase`管道和1中的功能完全相同。\n ", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { - "original": "

\n The control has been visited.\n

", - "translation": "

\n 控件被访问过。\n

", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "Formats a number as text.", + "translation": "把数字格式化为文本。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { - "original": "

\n The control's value has changed.\n

", - "translation": "

\n 控件的值变化了。\n

", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "The Angular `number` pipe is similar.\n It provides more functionality when defining\n the decimal places, as shown in the second example above.", + "translation": "Angular的`number`管道很相似。\n 但在指定小数点位置时,它提供了更多的功能,如第二个范例所示。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { - "original": "

\n The control's value is valid.\n

", - "translation": "

\n 控件的值有效。\n

", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "Angular also has a `percent` pipe, which formats a number as a local percentage\n as shown in the third example.", + "translation": "Angular还有一个`percent`管道,它把一个数组格式化为本地化的(local)百分比格式,如第三个范例所示。\n ", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { - "original": "Temporarily add a [template reference variable](guide/template-syntax#ref-vars) named `spy`\nto the _Name_ `` tag and use it to display the input's CSS classes.", - "translation": "往姓名``标签上添加名叫 **spy** 的临时[模板引用变量](guide/template-syntax#ref-vars),\n然后用这个 spy 来显示它上面的所有 CSS 类。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "Displays the collection in the order specified by the expression.\n In this example, the movie title orders the `movieList`.", + "translation": "使用表达式中所指定的方式对集合进行排序。\n 在这个例子中,`movieList`被根据movie的title排序了。\n ", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { - "original": "Now run the app and look at the _Name_ input box.\nFollow these steps *precisely*:", - "translation": "现在,运行本应用,并让*姓名*输入框获得焦点。\n然后严格按照下面四个步骤来做:", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { - "original": "可以在输入框的左侧添加带颜色的竖条,用于标记必填字段和无效输入:", - "translation": "
\n \"无效表单\"\n
", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "NgModules, defined with the `NgModule` decorator, serve the same purpose:", + "translation": "Angular的模块用`NgModule`装饰器进行定义,有如下用途:", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { - "original": "You achieve this effect by adding these class definitions to a new `forms.css` file\nthat you add to the project as a sibling to `index.html`:", - "translation": "在新建的`forms.css`文件中,添加两个样式来实现这一效果。把这个文件添加到项目中,与`index.html`相邻。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "* `imports`: specifies the list of other modules that this module depends upon", + "translation": "`imports`: 指定当前模块依赖的其它模块列表", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { - "original": "Update the `` of `index.html` to include this style sheet:", - "translation": "更新`index.html`中的``,以包含这个样式表:", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "* `declaration`: keeps track of your components, pipes, and directives.", + "translation": "`declaration`: 用于记录组件、管道和指令。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { - "original": "## Show and hide validation error messages", - "translation": "## 显示和隐藏验证错误信息", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "For more information on modules, see [NgModules](guide/ngmodule).", + "translation": "要了解关于模块的更多知识,参见[NgModules](guide/ngmodule)。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { - "original": "You can improve the form. The _Name_ input box is required and clearing it turns the bar red.\nThat says something is wrong but the user doesn't know *what* is wrong or what to do about it.\nLeverage the control's state to reveal a helpful message.", - "translation": "我们能做的更好。“Name” 输入框是必填的,清空它会让左侧的条变红。这表示*某些东西*是错的,但我们不知道错在哪里,或者如何纠正。\n 可以借助`ng-invalid`类来给出有用的提示。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { - "original": "You control visibility of the name error message by binding properties of the `name`\ncontrol to the message `
` element's `hidden` property.", - "translation": "我们把`div`元素的`hidden`属性绑定到`name`控件的属性,这样就可以控制“姓名”字段错误信息的可见性了。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "### Component class", + "translation": "### 组件类", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { - "original": "In this example, you hide the message when the control is valid or pristine;\n\"pristine\" means the user hasn't changed the value since it was displayed in this form.", - "translation": "上例中,当控件是有效的 (valid) 或全新的 (pristine) 时,隐藏消息。\n“全新的”意味着从它被显示在表单中开始,用户还从未修改过它的值。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "In Angular, you create a component class.", + "translation": "在Angular中,我们写组件类。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { - "original": "This user experience is the developer's choice. Some developers want the message to display at all times.\nIf you ignore the `pristine` state, you would hide the message only when the value is valid.\nIf you arrive in this component with a new (blank) hero or an invalid hero,\nyou'll see the error message immediately, before you've done anything.", - "translation": "这种用户体验取决于开发人员的选择。有些人会希望任何时候都显示这条消息。\n如果忽略了`pristine`状态,就会只在值有效时隐藏此消息。\n如果往这个组件中传入全新(空)的英雄,或者无效的英雄,将立刻看到错误信息 —— 虽然我们还啥都没做。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "NOTE: If you are using TypeScript with AngularJS, you must use the `export` keyword to export the component class.", + "translation": "注意:如果你正在用TypeScript写AngularJS,那么必须用`export`关键字来导出组件类。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { - "original": "Some developers want the message to display only when the user makes an invalid change.\nHiding the message while the control is \"pristine\" achieves that goal.\nYou'll see the significance of this choice when you add a new hero to the form.", - "translation": "有些人会为这种行为感到不安。它们希望只有在用户做出无效的更改时才显示这个消息。\n如果当控件是“全新”状态时也隐藏消息,就能达到这个目的。\n在往表单中添加新英雄时,将看到这种选择的重要性。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "For more information, see the [Components](guide/architecture#components) \n section of the [Architecture Overview](guide/architecture) page.", + "translation": "要了解关于组件的更多信息,参见[架构概览](guide/architecture)中的[组件](guide/architecture#components)部分。\n ", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { - "original": "The hero *Alter Ego* is optional so you can leave that be.", - "translation": "英雄的*第二人格*是可选项,所以不用改它。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "### Dependency injection", + "translation": "### 依赖注入", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { - "original": "Hero *Power* selection is required.\nYou can add the same kind of error handling to the ``上添加相同的错误处理。\n 但没有必要,这个选择框已经限制了“超能力”只能选有效值。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "In AngularJS, you pass in any dependencies as controller function arguments.\n This example injects a `MovieService`.", + "translation": "在AngularJS中,我们把所有依赖都作为控制器函数的参数。\n 在这个例子中,我们注入了一个`MovieService`。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { - "original": "Now you'll add a new hero in this form.\nPlace a *New Hero* button at the bottom of the form and bind its click event to a `newHero` component method.", - "translation": "我们希望在这个表单中添加新的英雄。\n 在表单的底部放置“New Hero(新增英雄)”按钮,并把它的点击事件绑定到`newHero`组件。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "To guard against minification problems, tell Angular explicitly\n that it should inject an instance of the `MovieService` in the first parameter.", + "translation": "我们还通过在第一个参数明确告诉Angular它应该注入一个`MovieService`的实例,以防止在最小化时出现问题。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { - "original": "Run the application again, click the *New Hero* button, and the form clears.\nThe *required* bars to the left of the input box are red, indicating invalid `name` and `power` properties.\nThat's understandable as these are required fields.\nThe error messages are hidden because the form is pristine; you haven't changed anything yet.", - "translation": "再次运行应用,点击 *New Hero* 按钮,表单被清空了。\n输入框左侧的*必填项*竖条是红色的,表示`name`和`power`属性是无效的。\n这可以理解,因为有一些必填字段。\n错误信息是隐藏的,因为表单还是全新的,还没有修改任何东西。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "### Dependency injection", + "translation": "### 依赖注入", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { - "original": "Enter a name and click *New Hero* again.\nThe app displays a _Name is required_ error message. \nYou don't want error messages when you create a new (empty) hero.\nWhy are you getting one now?", - "translation": "输入名字,再次点击 *New Hero* 按钮。\n这次,出现了错误信息!为什么?我们不希望显示新(空)的英雄时,出现错误信息。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "In Angular, you pass in dependencies as arguments to the component class constructor.\n This example injects a `MovieService`.\n The first parameter's TypeScript type tells Angular what to inject, even after minification.", + "translation": "在Angular中,我们把依赖作为组件构造函数的参数传入。\n 在这个例子中,我们注入了一个`MovieService`。\n 即使在最小化之后,第一个参数的TypeScript类型也会告诉Angular它该注入什么。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { - "original": "Inspecting the element in the browser tools reveals that the *name* input box is _no longer pristine_.\nThe form remembers that you entered a name before clicking *New Hero*.\nReplacing the hero *did not restore the pristine state* of the form controls.", - "translation": "使用浏览器工具审查这个元素就会发现,这个 *name* 输入框并不是全新的。\n表单记得我们在点击 *New Hero* 前输入的名字。\n更换了英雄*并不会重置控件的“全新”状态*。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "For more information, see the [Dependency injection](guide/architecture#dependency-injection) \n section of the [Architecture Overview](guide/architecture).", + "translation": "要了解关于依赖注入的更多信息,参见[架构概览](guide/architecture)中的[依赖注入](guide/architecture#dependency-injection)部分。\n ", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { - "original": "You have to clear all of the flags imperatively, which you can do\nby calling the form's `reset()` method after calling the `newHero()` method.", - "translation": "我们必须清除所有标记,在调用`newHero()`方法后调用表单的`reset()`方法即可。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "## Style sheets", + "translation": "## 样式表", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { - "original": "Now clicking \"New Hero\" resets both the form and its control flags.", - "translation": "现在点击“New Hero”重设表单和它的控制标记。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "Style sheets give your application a nice look.\nIn AngularJS, you specify the style sheets for your entire application.\nAs the application grows over time, the styles for the many parts of the application\nmerge, which can cause unexpected results.\nIn Angular, you can still define style sheets for your entire application. But now you can\nalso encapsulate a style sheet within a specific component.", + "translation": "样式表美化我们的应用程序。\n在AngularJS中,我们为整个应用程序指定样式表。\n当应用程序成长一段时间之后,应用程序中很多部分的样式会被合并,导致无法预计的后果。\n在Angular中,我们仍然会为整个应用程序定义样式,不过现在也可以把样式表封装在特定的组件中。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { - "original": "## Submit the form with _ngSubmit_", - "translation": "## 使用 *ngSubmit* 提交该表单", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "AngularJS, uses a `link` tag in the head section of the `index.html` file\n to define the styles for the application.", + "translation": "在AngularJS中,我们在`index.html`的`head`区使用`link`标签来为应用程序定义样式。\n ", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { - "original": "The user should be able to submit this form after filling it in.\nThe *Submit* button at the bottom of the form\ndoes nothing on its own, but it will\ntrigger a form submit because of its type (`type=\"submit\"`).", - "translation": "在填表完成之后,用户还应该能提交这个表单。\n“Submit(提交)”按钮位于表单的底部,它自己不做任何事,但因为有特殊的 type 值 (`type=\"submit\"`),所以会触发表单提交。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "### Link tag", + "translation": "### Link标签", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { - "original": "A \"form submit\" is useless at the moment.\nTo make it useful, bind the form's `ngSubmit` event property\nto the hero form component's `onSubmit()` method:", - "translation": "现在这样仅仅触发“表单提交”是没用的。\n要让它有用,就要把该表单的`ngSubmit`事件属性绑定到英雄表单组件的`onSubmit()`方法上:", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "In Angular, you can continue to use the link tag to define the styles for your application in the `index.html` file.\n But now you can also encapsulate styles for your components.", + "translation": "在Angular2中,我们可以继续在`index.html`中使用link标签来为应用程序定义样式。\n 但是也能在组件中封装样式。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { - "original": "You'd already defined a template reference variable,\n`#heroForm`, and initialized it with the value \"ngForm\".\nNow, use that variable to access the form with the Submit button.", - "translation": "我们已经定义了一个模板引用变量`#heroForm`,并且把赋值为“ngForm”。\n现在,就可以在“Submit”按钮中访问这个表单了。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "### StyleUrls\n In Angular, you can use the `styles` or `styleUrls` property of the `@Component` metadata to define\n a style sheet for a particular component.", + "translation": "在Angular中,我们可以在`@Component`的元数据中使用`styles`或`styleUrls`属性来为一个特定的组件定义样式表。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { - "original": "You'll bind the form's overall validity via\nthe `heroForm` variable to the button's `disabled` property\nusing an event binding. Here's the code:", - "translation": "我们要把表单的总体有效性通过`heroForm`变量绑定到此按钮的`disabled`属性上,代码如下:", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "This allows you to set appropriate styles for individual components that won’t leak into\n other parts of the application.", + "translation": "这让我们可以为各个组件设置合适的样式,而不用担心它被泄漏到程序中的其它部分。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { - "original": "If you run the application now, you find that the button is enabled—although\nit doesn't do anything useful yet.", - "translation": "重新运行应用。表单打开时,状态是有效的,按钮是可用的。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "# Animations", + "translation": "# 动画", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/animations.md" }, { - "original": "Now if you delete the Name, you violate the \"required\" rule, which\nis duly noted in the error message.\nThe *Submit* button is also disabled.", - "translation": "现在,如果我们删除*姓名*,就会违反“必填姓名”规则,就会像以前那样显示出错误信息。同时,Submit 按钮也被禁用了。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "Motion is an important aspect in the design of modern web applications. Good\nuser interfaces transition smoothly between states with engaging animations\nthat call attention where it's needed. Well-designed animations can make a UI not only\nmore fun but also easier to use.", + "translation": "动画是现代Web应用设计中一个很重要的方面。我们希望用户界面能在不同的状态之间更平滑的转场。如果需要,还可以用适当的动画来吸引注意力。\n设计良好的动画不但会让UI更有趣,还会让它更容易使用。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/animations.md" }, { - "original": "Not impressed? Think about it for a moment. What would you have to do to\nwire the button's enable/disabled state to the form's validity without Angular's help?", - "translation": "没感动吗?再想一会儿。如果没有 Angular `NgForm`的帮助,又该怎么让按钮的禁用/启用状态和表单的有效性关联起来呢?", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "动画是现代Web应用设计中一个很重要的方面。我们希望用户界面能在不同的状态之间更平滑的转场。如果需要,还可以用适当的动画来吸引注意力。\n设计良好的动画不但会让UI更有趣,还会让它更容易使用。", + "translation": "## Overview\n## 概述", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/animations.md" }, { - "original": "For you, it was as simple as this:", - "translation": "有了 Angular,它就是这么简单:", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "Angular's animation system lets you build animations that run with the same kind of native\nperformance found in pure CSS animations. You can also tightly integrate your\nanimation logic with the rest of your application code, for ease of control.", + "translation": "Angular的动画系统赋予了制作各种动画效果的能力,以构建出与原生CSS动画性能相同的动画。\n我们也获得了额外的让动画逻辑与其它应用代码紧紧集成在一起的能力,这让动画可以被更容易的触发与控制。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/animations.md" }, { - "original": "1. Define a template reference variable on the (enhanced) form element.", - "translation": "定义模板引用变量,放在(强化过的)form 元素上", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "Angular animations are built on top of the standard [Web Animations API](https://w3c.github.io/web-animations/)\nand run natively on [browsers that support it](http://caniuse.com/#feat=web-animation).", + "translation": "Angular动画是基于标准的[Web动画API(Web Animations API)](https://w3c.github.io/web-animations/)构建的,它们在[支持此API的浏览器中](http://caniuse.com/#feat=web-animation)会用原生方式工作。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/animations.md" }, { - "original": "2. Refer to that variable in a button many lines away.", - "translation": "从很多行之外的按钮上引用这个变量。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "For other browsers, a polyfill is required. Grab\n[`web-animations.min.js` from GitHub](https://github.com/web-animations/web-animations-js) and\nadd it to your page.", + "translation": "至于其它浏览器,就需要一个填充库(polyfill)了。你可以[从这里获取`web-animations.min.js`](https://github.com/web-animations/web-animations-js),并把它加入你的页面中。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/animations.md" }, { - "original": "## Toggle two form regions (extra credit)", - "translation": "## 切换两个表单区域(额外的奖励)", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "The examples in this page are available as a .", + "translation": "本章中引用的这个例子可以到去体验。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/animations.md" }, { - "original": "Submitting the form isn't terribly dramatic at the moment.", - "translation": "提交表单还是不够激动人心。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "## Transitioning between two states", + "translation": "## 快速起步范例:在两个状态间转场", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/animations.md" }, { - "original": "An unsurprising observation for a demo. To be honest,\njazzing it up won't teach you anything new about forms.\nBut this is an opportunity to exercise some of your newly won\nbinding skills.\nIf you aren't interested, skip to this page's conclusion.", - "translation": "对演示来说,这个收场很平淡的。老实说,即使让它更出彩,也无法教给我们任何关于表单的新知识。\n但这是练习新学到的绑定技能的好机会。\n如果你不感兴趣,可以跳到本章的总结部分。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "You can build a simple animation that transitions an element between two states\ndriven by a model attribute.", + "translation": "我们来构建一个简单的动画,它会让一个元素用模型驱动的方式在两个状态之间转场。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/animations.md" }, { - "original": "For a more strikingly visual effect,\nhide the data entry area and display something else.", - "translation": "来实现一些更炫的视觉效果吧。\n 隐藏掉数据输入框,显示一些其它东西。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "Animations can be defined inside `@Component` metadata.", + "translation": "动画会被定义在`@Component`元数据中。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/animations.md" }, { - "original": "Wrap the form in a `
` and bind\nits `hidden` property to the `HeroFormComponent.submitted` property.", - "translation": "先把表单包裹进`
`中,再把它的`hidden`属性绑定到`HeroFormComponent.submitted`属性。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "With these, you can define an *animation trigger* called `heroState` in the component\nmetadata. It uses animations to transition between two states: `active` and `inactive`. When a\nhero is active, the element appears in a slightly larger size and lighter color.", + "translation": "通过这些,可以在组件元数据中定义一个名叫`heroState`的*动画触发器*。它在两个状态`active`和`inactive`之间进行转场。\n当英雄处于激活状态时,它会把该元素显示得稍微大一点、亮一点。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/animations.md" }, { - "original": "The main form is visible from the start because the\n`submitted` property is false until you submit the form,\nas this fragment from the `HeroFormComponent` shows:", - "translation": "主表单从一开始就是可见的,因为`submitted`属性是 false,直到提交了这个表单。\n来自`HeroFormComponent`的代码片段告诉了我们这一点:", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "In this example, you are defining animation styles (color and transform) inline in the\nanimation metadata.", + "translation": "在这个例子中,我们在元数据中用内联的方式定义了动画样式(`color`和`transform`)。在即将到来的一个Angular版本中,还将支持从组件的CSS样式表中提取样式。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/animations.md" }, { - "original": "When you click the *Submit* button, the `submitted` flag becomes true and the form disappears\nas planned.", - "translation": "当点击 Submit 按钮时,`submitted`标志会变成 true,并且表单像预想中一样消失了。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "Now, using the `[@triggerName]` syntax, attach the animation that you just defined to\none or more elements in the component's template.", + "translation": "我们刚刚定义了一个动画,但它还没有被用到任何地方。要想使用它,可以在模板中用`[@triggerName]`语法来把它附加到一个或多个元素上。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/animations.md" }, { - "original": "Now the app needs to show something else while the form is in the submitted state.\nAdd the following HTML below the `
` wrapper you just wrote:", - "translation": "现在,当表单处于已提交状态时,需要显示一些别的东西。\n在刚刚写的`
`包装下方,添加下列 HTML 语句:", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "Here, the animation trigger applies to every element repeated by an `ngFor`. Each of\nthe repeated elements animates independently. The value of the\nattribute is bound to the expression `hero.state` and is always either `active` or `inactive`.", + "translation": "这里,我们把该动画触发器添加到了由`ngFor`重复出来的每一个元素上。每个重复出来的元素都有独立的动画效果。\n然后把`@triggerName`属性(Attribute)的值设置成表达式`hero.state`。这个值应该或者是`inactive`或者是`active`,因为我们刚刚为它们俩定义过动画状态。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/animations.md" }, { - "original": "There's the hero again, displayed read-only with interpolation bindings.\nThis `
` appears only while the component is in the submitted state.", - "translation": "英雄又出现了,它通过插值表达式绑定显示为只读内容。\n这一小段 HTML 只在组件处于已提交状态时才会显示。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "With this setup, an animated transition appears whenever a hero object changes state.\nHere's the full component implementation:", + "translation": "通过这些设置,一旦英雄对象的状态发生了变化,就会触发一个转场动画。下面是完整的组件实现:", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/animations.md" }, { - "original": "The HTML includes an *Edit* button whose click event is bound to an expression\nthat clears the `submitted` flag.", - "translation": "这段HTML包含一个 “Edit(编辑)”按钮,将 click 事件绑定到表达式,用于清除`submitted`标志。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "## States and transitions", + "translation": "## 状态与转场", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/animations.md" }, { - "original": "When you click the *Edit* button, this block disappears and the editable form reappears.", - "translation": "当点*Edit*按钮时,这个只读块消失了,可编辑的表单重新出现了。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "Angular animations are defined as logical **states** and **transitions**\nbetween states.", + "translation": "Angular动画是由**状态**和**状态之间的转场效果**所定义的。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/animations.md" }, { - "original": "## Conclusion", - "translation": "## 结论", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "An animation state is a string value that you define in your application code. In the example\nabove, the states `'active'` and `'inactive'` are based on the logical state of\nhero objects. The source of the state can be a simple object attribute, as it was in this case,\nor it can be a value computed in a method. The important thing is that you can read it into the\ncomponent's template.", + "translation": "动画状态是一个由程序代码中定义的字符串值。在上面的例子中,基于英雄对象的逻辑状态,我们使用了`'active'`和`'inactive'`这两种状态。\n状态的来源可以是像本例中这样简单的对象属性,也可以是由方法计算出来的值。重点是,我们得能从组件模板中读取它。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/animations.md" }, { - "original": "The Angular form discussed in this page takes advantage of the following\nframework features to provide support for data modification, validation, and more:", - "translation": "本章讨论的 Angular 表单技术利用了下列框架特性来支持数据修改、验证和更多操作:", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "We can define *styles* for each animation state:", + "translation": "我们可以为每个动画状态定义了*一组样式*:", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/animations.md" }, { - "original": "* An Angular HTML form template.", - "translation": "Angular HTML 表单模板。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "These `state` definitions specify the *end styles* of each state.\nThey are applied to the element once it has transitioned to that state, and stay\n*as long as it remains in that state*. In effect, you're defining what styles the element has in different states.", + "translation": "这些`state`具体定义了每个状态的*最终样式*。一旦元素转场到那个状态,该样式就会被应用到此元素上,*当它留在此状态时*,这些样式也会一直保持着。\n从这个意义上讲,这里其实并不只是在定义动画,而是在定义该元素在不同状态时应该具有的样式。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/animations.md" }, { - "original": "* A form component class with a `@Component` decorator.", - "translation": "带有`@Component`装饰器的表单组件类。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "After you define states, you can define *transitions* between the states. Each transition\ncontrols the timing of switching between one set of styles and the next:", + "translation": "定义完状态,就能定义在状态之间的各种*转场*了。每个转场都会控制一条在一组样式和下一组样式之间切换的时间线:", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/animations.md" }, { - "original": "* Handling form submission by binding to the `NgForm.ngSubmit` event property.", - "translation": "通过绑定到`NgForm.ngSubmit`事件属性来处理表单提交。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "If several transitions have the same timing configuration, you can combine\nthem into the same `transition` definition:", + "translation": "如果多个转场都有同样的时间线配置,就可以把它们合并进同一个`transition`定义中:", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/animations.md" }, { - "original": "* Template-reference variables such as `#heroForm` and `#name`.", - "translation": "模板引用变量,例如`#heroForm`和`#name`。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "When both directions of a transition have the same timing, as in the previous\nexample, you can use the shorthand syntax `<=>`:", + "translation": "如果要对同一个转场的两个方向都使用相同的时间线(就像前面的例子中那样),就可以使用`<=>`这种简写语法:", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/animations.md" }, { - "original": "* `[(ngModel)]` syntax for two-way data binding.", - "translation": "`[(ngModel)]`语法用来实现双向数据绑定。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "You can also apply a style during an animation but not keep it around\nafter the animation finishes. You can define such styles inline, in the `transition`. In this example,\nthe element receives one set of styles immediately and is then animated to the next.\nWhen the transition finishes, none of these styles are kept because they're not\ndefined in a `state`.", + "translation": "有时希望一些样式只在动画期间生效,但在结束后并不保留它们。这时可以把这些样式内联在`transition`中进行定义。\n在这个例子中,该元素会立刻获得一组样式,然后动态转场到下一个状态。当转场结束时,这些样式并不会被保留,因为它们并没有被定义在`state`中。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/animations.md" }, { - "original": "* The use of `name` attributes for validation and form-element change tracking.", - "translation": "`name`属性的用途是有效性验证和对表单元素的变更进行追踪。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "### The wildcard state `*`", + "translation": "### `*`(通配符)状态", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/animations.md" }, { - "original": "* The reference variable’s `valid` property on input controls to check if a control is valid and show/hide error messages.", - "translation": "指向 input 控件的引用变量上的`valid`属性,可用于检查控件是否有效、是否显示/隐藏错误信息。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "The `*` (\"wildcard\") state matches *any* animation state. This is useful for defining styles and\ntransitions that apply regardless of which state the animation is in. For example:", + "translation": "`*`(通配符)状态匹配*任何*动画状态。当定义那些不需要管当前处于什么状态的样式及转场时,这很有用。比如:", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/animations.md" }, { - "original": "* Controlling the *Submit* button's enabled state by binding to `NgForm` validity.", - "translation": "通过绑定到`NgForm`的有效性状态,控制*Submit*按钮的禁用状态。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "* The `active => *` transition applies when the element's state changes from `active` to anything else.", + "translation": "当该元素的状态从`active`变成任何其它状态时,`active => *`转场都会生效。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/animations.md" }, { - "original": "* Custom CSS classes that provide visual feedback to users about invalid controls.", - "translation": "定制 CSS 类来给用户提供无效控件的视觉反馈。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "* The `* => *` transition applies when *any* change between two states takes place.", + "translation": "当在*任意*两个状态之间切换时,`* => *`转场都会生效。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/animations.md" }, { - "original": "The final project folder structure should look like this:", - "translation": "最终的项目目录结构是这样的:", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "### The `void` state", + "translation": "### `void`状态", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/animations.md" }, { - "original": "Here’s the code for the final version of the application:", - "translation": "这里是源码的最终版本:", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "The special state called `void` can apply to any animation. It applies\nwhen the element is *not* attached to a view, perhaps because it has not yet been\nadded or because it has been removed. The `void` state is useful for defining enter and\nleave animations.", + "translation": "有一种叫做`void`的特殊状态,它可以应用在任何动画中。它表示元素*没有*被附加到视图。这种情况可能是由于它尚未被添加进来或者已经被移除了。\n`void`状态在定义“进场”和“离场”的动画时会非常有用。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/animations.md" }, { - "original": "# Forms", - "translation": "# 表单", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/examples/cli-quickstart/README.md" + "original": "For example the `* => void` transition applies when the element leaves the view,\nregardless of what state it was in before it left.", + "translation": "比如当一个元素离开视图时,`* => void`转场就会生效,而不管它在离场以前是什么状态。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/animations.md" }, { - "original": "Forms are the mainstay of business applications.\nYou use forms to log in, submit a help request, place an order, book a flight,\nschedule a meeting, and perform countless other data-entry tasks.", - "translation": "表单是商业应用的支柱,我们用它来执行登录、求助、下单、预订机票、安排会议,以及不计其数的其它数据录入任务。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/examples/cli-quickstart/README.md" + "original": "The wildcard state `*` also matches `void`.", + "translation": "`*`通配符状态也能匹配`void`。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/animations.md" }, { - "original": "In developing a form, it's important to create a data-entry experience that guides the\nuser efficiently and effectively through the workflow.", - "translation": "在开发表单时,创建数据方面的体验是非常重要的,它能指引用户明细、高效的完成工作流程。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/examples/cli-quickstart/README.md" + "original": "## Example: Entering and leaving", + "translation": "## 例子:进场与离场", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/animations.md" }, { - "original": "Developing forms requires design skills (which are out of scope for this page), as well as framework support for\n*two-way data binding, change tracking, validation, and error handling*,\nwhich you'll learn about on this page.", - "translation": "开发表单需要设计能力(那超出了本章的范围),而框架支持*双向数据绑定、变更检测、验证和错误处理*,而本章我们会接触到它们。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/examples/cli-quickstart/README.md" + "original": "Using the `void` and `*` states you can define transitions that animate the\nentering and leaving of elements:", + "translation": "使用`void`和`*`状态,可以定义元素进场与离场时的转场动画:", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/animations.md" }, { - "original": "This page shows you how to build a simple form from scratch. Along the way you'll learn how to:", - "translation": "这个页面演示了如何从草稿构建一个简单的表单。这个过程中你将学会如何:", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/examples/cli-quickstart/README.md" + "original": "* Enter: `void => *`", + "translation": "进场:`void => *`", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/animations.md" }, { - "original": "* Build an Angular form with a component and template.", - "translation": "用组件和模板构建 Angular 表单", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/examples/cli-quickstart/README.md" + "original": "* Leave: `* => void`", + "translation": "离场:`* => void`", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/animations.md" }, { - "original": "* Use `ngModel` to create two-way data bindings for reading and writing input-control values.", - "translation": "用`ngModel`创建双向数据绑定,以读取和写入输入控件的值", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/examples/cli-quickstart/README.md" + "original": "For example, in the `animations` array below there are two transitions that use\nthe `void => *` and `* => void` syntax to animate the element in and out of the view.", + "translation": "例如,在下面的`animations`数组中,这两个转场语句使用`void => *`和`* => void`语法来让该元素以动画形式进入和离开当前视图。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/animations.md" }, { - "original": "* Track state changes and the validity of form controls.", - "translation": "跟踪状态的变化,并验证表单控件", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/examples/cli-quickstart/README.md" + "original": "Note that in this case the styles are applied to the void state directly in the\ntransition definitions, and not in a separate `state(void)` definition. Thus, the transforms\nare different on enter and leave: the element enters from the left\nand leaves to the right.", + "translation": "注意,在这个例子中,这些样式在转场定义中被直接应用到了`void`状态,但并没有一个单独的`state(void)`定义。\n这么做是因为希望在进场与离场时使用不一样的转换效果:元素从左侧进场,从右侧离开。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/animations.md" }, { - "original": "* Provide visual feedback using special CSS classes that track the state of the controls.", - "translation": "使用特殊的CSS类来跟踪控件的状态并给出视觉反馈", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/examples/cli-quickstart/README.md" + "original": "These two common animations have their own aliases:", + "translation": "这两个常见的动画有自己的别名:", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/animations.md" }, { - "original": "* Display validation errors to users and enable/disable form controls.", - "translation": "向用户显示验证错误提示,以及启用/禁用表单控件", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/examples/cli-quickstart/README.md" + "original": "## Example: Entering and leaving from different states", + "translation": "## 范例:从不同的状态下进场和离场", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/animations.md" }, { - "original": "* Share information across HTML elements using template reference variables.", - "translation": "使用模板引用变量在 HTML 元素之间共享信息", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/examples/cli-quickstart/README.md" + "original": "You can also combine this animation with the earlier state transition animation by\nusing the hero state as the animation state. This lets you configure\ndifferent transitions for entering and leaving based on what the state of the hero\nis:", + "translation": "通过把英雄的状态用作动画的状态,还能把该动画跟以前的转场动画组合成一个复合动画。这让我们能根据该英雄的当前状态为其配置不同的进场与离场动画:", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/animations.md" }, { - "original": "You can run the in Plunker and download the code from there.", - "translation": "你可以在Plunker中运行,并且从那里下载代码。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/examples/cli-quickstart/README.md" + "original": "* Inactive hero enter: `void => inactive`", + "translation": "非激活英雄进场:`void => inactive`", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/animations.md" }, { - "original": "## Template-driven forms", - "translation": "## 模板驱动的表单", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/examples/cli-quickstart/README.md" + "original": "* Active hero enter: `void => active`", + "translation": "激活英雄进场:`void => active`", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/animations.md" }, { - "original": "You can build forms by writing templates in the Angular [template syntax](guide/template-syntax) with\nthe form-specific directives and techniques described in this page.", - "translation": "通常,使用 Angular [模板语法](guide/template-syntax)编写模板,结合本章所描述的表单专用指令和技术来构建表单。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/examples/cli-quickstart/README.md" + "original": "* Inactive hero leave: `inactive => void`", + "translation": "非激活英雄离场:`inactive => void`", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/animations.md" }, { - "original": "You can also use a reactive (or model-driven) approach to build forms.\nHowever, this page focuses on template-driven forms.", - "translation": "你还可以使用响应式(也叫模型驱动)的方式来构建表单。不过本章中只介绍模板驱动表单。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/examples/cli-quickstart/README.md" + "original": "* Active hero leave: `active => void`", + "translation": "激活英雄离场:`active => void`", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/animations.md" }, { - "original": "You can build almost any form with an Angular template—login forms, contact forms, and pretty much any business form.\nYou can lay out the controls creatively, bind them to data, specify validation rules and display validation errors,\nconditionally enable or disable specific controls, trigger built-in visual feedback, and much more.", - "translation": "利用 Angular 模板,可以构建几乎所有表单 — 登录表单、联系人表单…… 以及任何的商务表单。\n 可以创造性的摆放各种控件、把它们绑定到数据、指定校验规则、显示校验错误、有条件的禁用或\n 启用特定的控件、触发内置的视觉反馈等等,不胜枚举。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/examples/cli-quickstart/README.md" + "original": "This gives you fine-grained control over each transition:", + "translation": "现在就对每一种转场都有了细粒度的控制:", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/animations.md" }, { - "original": "Angular makes the process easy by handling many of the repetitive, boilerplate tasks you'd\notherwise wrestle with yourself.", - "translation": "它用起来很简单,这是因为 Angular 处理了大多数重复、单调的任务,这让我们可以不必亲自操刀、身陷其中。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/examples/cli-quickstart/README.md" + "original": "## Animatable properties and units", + "translation": "## 可动的(Animatable)属性与单位", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/animations.md" }, { - "original": "You'll learn to build a template-driven form that looks like this:", - "translation": "我们将学习构建如下的“模板驱动”表单:", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/examples/cli-quickstart/README.md" + "original": "Since Angular's animation support builds on top of Web Animations, you can animate any property\nthat the browser considers *animatable*. This includes positions, sizes, transforms, colors,\nborders, and many others. The W3C maintains\n[a list of animatable properties](https://www.w3.org/TR/css3-transitions/#animatable-properties)\non its [CSS Transitions page](https://www.w3.org/TR/css3-transitions).", + "translation": "由于Angular的动画支持是基于Web Animations标准的,所以也能支持浏览器认为可以*参与动画*的任何属性。这些属性包括位置(position)、大小(size)、变换(transform)、颜色(color)、边框(border)等很多属性。W3C维护着\n[一个“可动”属性列表](https://www.w3.org/TR/css3-transitions/#animatable-properties)。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/animations.md" }, { - "original": "The *Hero Employment Agency* uses this form to maintain personal information about heroes.\nEvery hero needs a job. It's the company mission to match the right hero with the right crisis.", - "translation": "这里是*英雄职业介绍所*,使用这个表单来维护候选英雄们的个人信息。每个英雄都需要一份工作。\n公司的使命就是让合适的英雄去应对恰当的危机!", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/examples/cli-quickstart/README.md" + "original": "For positional properties that have a numeric value, you can define a unit by providing\nthe value as a string with the appropriate suffix:", + "translation": "尺寸类属性(如位置、大小、边框等)包括一个数字值和一个用来定义长度单位的后缀:", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/animations.md" }, { - "original": "Two of the three fields on this form are required. Required fields have a green bar on the left to make them easy to spot.", - "translation": "表单中的三个字段,其中两个是必填的。必填的字段在左侧有个绿色的竖条,方便用户分辨哪些是必填项。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/examples/cli-quickstart/README.md" + "original": "If you don't provide a unit when specifying dimension, Angular assumes the default of `px`:", + "translation": "对大多数尺寸类属性而言,还能只定义一个数字,那就表示它使用的是像素(px)数:", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/animations.md" }, { - "original": "If you delete the hero name, the form displays a validation error in an attention-grabbing style:", - "translation": "如果删除了英雄的名字,表单就会用醒目的样式把验证错误显示出来。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/examples/cli-quickstart/README.md" + "original": "* `50` is the same as saying `'50px'`", + "translation": "`50`相当于`'50px'`", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/animations.md" }, { - "original": "如果删除了英雄的名字,表单就会用醒目的样式把验证错误显示出来。", - "translation": "
\n \"无效!名字是必填项\"\n
", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/examples/cli-quickstart/README.md" + "original": "## Automatic property calculation", + "translation": "## 自动属性值计算", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/animations.md" }, { - "original": "Note that the *Submit* button is disabled, and the \"required\" bar to the left of the input control changes from green to red.", - "translation": "注意,提交按钮被禁用了,而且输入控件左侧的“必填”条从绿色变为了红色。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/examples/cli-quickstart/README.md" + "original": "Sometimes you don't know the value of a dimensional style property until runtime.\nFor example, elements often have widths and heights that\ndepend on their content and the screen size. These properties are often tricky\nto animate with CSS.", + "translation": "有时候,我们想在动画中使用的尺寸类样式,它的值在开始运行之前都是不可知的。比如,元素的宽度和高度往往依赖于它们的内容和屏幕的尺寸。处理这些属性对CSS动画而言通常是相当棘手的。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/animations.md" }, { - "original": "You can customize the colors and location of the \"required\" bar with standard CSS.", - "translation": "稍后,会使用标准 CSS 来定制“必填”条的颜色和位置。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/examples/cli-quickstart/README.md" + "original": "In these cases, you can use a special `*` property value so that the value of the\nproperty is computed at runtime and then plugged into the animation.", + "translation": "如果用Angular动画,就可以用一个特殊的`*`属性值来处理这种情况。该属性的值将会在运行期被计算出来,然后插入到这个动画中。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/animations.md" }, { - "original": "You'll build this form in small steps:", - "translation": "我们将一点点构建出此表单:", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/examples/cli-quickstart/README.md" + "original": "In this example, the leave animation takes whatever height the element has before it\nleaves and animates from that height to zero:", + "translation": "这个例子中的“离场”动画会取得该元素在离场前的高度,并且把它从这个高度用动画转场到0高度:", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/animations.md" }, { - "original": "1. Create the `Hero` model class.", - "translation": "创建`Hero`模型类", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/examples/cli-quickstart/README.md" + "original": "## Animation timing", + "translation": "## 动画时间线", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/animations.md" }, { - "original": "1. Create the component that controls the form.", - "translation": "创建控制此表单的组件。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/examples/cli-quickstart/README.md" + "original": "There are three timing properties you can tune for every animated transition:\nthe duration, the delay, and the easing function. They are all combined into\na single transition *timing string*.", + "translation": "对每一个动画转场效果,有三种时间线属性可以调整:持续时间(duration)、延迟(delay)和缓动(easing)函数。它们被合并到了一个单独的*转场时间线字符串*。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/animations.md" }, { - "original": "1. Create a template with the initial form layout.", - "translation": "创建具有初始表单布局的模板。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/examples/cli-quickstart/README.md" + "original": "### Duration", + "translation": "### 持续时间", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/animations.md" }, { - "original": "1. Bind data properties to each form control using the `ngModel` two-way data-binding syntax.", - "translation": "使用`ngModel`双向数据绑定语法把数据属性绑定到每个表单输入控件。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/examples/cli-quickstart/README.md" + "original": "The duration controls how long the animation takes to run from start to finish.\nYou can define a duration in three ways:", + "translation": "持续时间控制动画从开始到结束要花多长时间。可以用三种方式定义持续时间:", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/animations.md" }, { - "original": "1. Add a `name` attribute to each form-input control.", - "translation": "往每个表单输入控件上添加`name`属性 (attribute)。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/examples/cli-quickstart/README.md" + "original": "* As a plain number, in milliseconds: `100`", + "translation": "作为一个普通数字,以毫秒为单位,如:`100`", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/animations.md" }, { - "original": "1. Add custom CSS to provide visual feedback.", - "translation": "添加自定义 CSS 来提供视觉反馈。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/examples/cli-quickstart/README.md" + "original": "* In a string, as milliseconds: `'100ms'`", + "translation": "作为一个字符串,以毫秒为单位,如:`'100ms'`", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/animations.md" }, { - "original": "1. Show and hide validation-error messages.", - "translation": "显示和隐藏有效性验证的错误信息。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/examples/cli-quickstart/README.md" + "original": "* In a string, as seconds: `'0.1s'`", + "translation": "作为一个字符串,以秒为单位,如:`'0.1s'`", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/animations.md" }, { - "original": "1. Handle form submission with *ngSubmit*.", - "translation": "使用 **ngSubmit** 处理表单提交。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/examples/cli-quickstart/README.md" + "original": "### Delay", + "translation": "### 延迟", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/animations.md" }, { - "original": "1. Disable the form’s *Submit* button until the form is valid.", - "translation": "禁用此表单的提交按钮,直到表单变为有效。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/examples/cli-quickstart/README.md" + "original": "The delay controls the length of time between the animation trigger and the beginning\nof the transition. You can define one by adding it to the same string\nfollowing the duration. It also has the same format options as the duration:", + "translation": "延迟控制的是在动画已经触发但尚未真正开始转场之前要等待多久。可以把它添加到字符串中的持续时间后面,它的选项格式也跟持续时间是一样的:", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/animations.md" }, { - "original": "## Setup", - "translation": "## 搭建", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/examples/cli-quickstart/README.md" + "original": "* Wait for 100ms and then run for 200ms: `'0.2s 100ms'`", + "translation": "等待100毫秒,然后运行200毫秒:`'0.2s 100ms'`。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/animations.md" }, { - "original": "Follow the [setup](guide/setup) instructions for creating a new project\nnamed angular-forms.", - "translation": "按照[搭建本地开发环境](guide/setup)的说明,创建一个名为angular-forms的新项目。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/examples/cli-quickstart/README.md" + "original": "### Easing", + "translation": "### 缓动函数", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/animations.md" }, { - "original": "## Create the Hero model class", - "translation": "## 创建 Hero 模型类", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/examples/cli-quickstart/README.md" + "original": "The [easing function](http://easings.net/) controls how the animation accelerates\nand decelerates during its runtime. For example, an `ease-in` function causes\nthe animation to begin relatively slowly but pick up speed as it progresses. You\ncan control the easing by adding it as a *third* value in the string after the duration\nand the delay (or as the *second* value when there is no delay):", + "translation": "[缓动函数](http://easings.net/)用于控制动画在运行期间如何加速和减速。比如:使用`ease-in`函数意味着动画开始时相对缓慢,然后在进行中逐步加速。可以通过在这个字符串中的持续时间和延迟后面添加*第三个*值来控制使用哪个缓动函数(如果没有定义延迟就作为*第二个*值)。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/animations.md" }, { - "original": "As users enter form data, you'll capture their changes and update an instance of a model.\nYou can't lay out the form until you know what the model looks like.", - "translation": "当用户输入表单数据时,需要捕获它们的变化,并更新到模型的实例中。\n除非知道模型里有什么,否则无法设计表单的布局。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/examples/cli-quickstart/README.md" + "original": "* Wait for 100ms and then run for 200ms, with easing: `'0.2s 100ms ease-out'`", + "translation": "等待100毫秒,然后运行200毫秒,并且带缓动:`'0.2s 100ms ease-out'`", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/animations.md" }, { - "original": "A model can be as simple as a \"property bag\" that holds facts about a thing of application importance.\nThat describes well the `Hero` class with its three required fields (`id`, `name`, `power`)\nand one optional field (`alterEgo`).", - "translation": "最简单的模型是个“属性包”,用来存放应用中一件事物的事实。\n这里使用三个必备字段 (`id`、`name`、`power`),和一个可选字段 (`alterEgo`,译注:中文含义是第二人格,例如 X 战警中的 Jean / 黑凤凰)。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/examples/cli-quickstart/README.md" + "original": "* Run for 200ms, with easing: `'0.2s ease-in-out'`", + "translation": "运行200毫秒,并且带缓动:`'0.2s ease-in-out'`", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/animations.md" }, { - "original": "In the `app` directory, create the following file with the given content:", - "translation": "在应用文件夹中创建下列文件:", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/examples/cli-quickstart/README.md" + "original": "### Example", + "translation": "### 例子", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/animations.md" }, { - "original": "It's an anemic model with few requirements and no behavior. Perfect for the demo.", - "translation": "这是一个少量需求和零行为的贫血模型。对演示来说很完美。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/examples/cli-quickstart/README.md" + "original": "Here are a couple of custom timings in action. Both enter and leave last for\n200 milliseconds, that is `0.2s`, but they have different easings. The leave begins after a\nslight delay of 10 milliseconds as specified in `'0.2s 10 ease-out'`:", + "translation": "这里是两个自定义时间线的动态演示。“进场”和“离场”都持续200毫秒,也就是`0.2s`,但它们有不同的缓动函数。“离场”动画会在100毫秒的延迟之后开始,也就是`'0.2s 10 ease-out'`:", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/animations.md" }, { - "original": "The TypeScript compiler generates a public field for each `public` constructor parameter and\nautomatically assigns the parameter’s value to that field when you create heroes.", - "translation": "TypeScript 编译器为每个`public`构造函数参数生成一个公共字段,在创建新的英雄实例时,自动把参数值赋给这些公共字段。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/examples/cli-quickstart/README.md" + "original": "## Multi-step animations with keyframes", + "translation": "## 基于关键帧(Keyframes)的多阶段动画", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/animations.md" }, { - "original": "The `alterEgo` is optional, so the constructor lets you omit it; note the question mark (?) in `alterEgo?`.", - "translation": "`alterEgo`是可选的,调用构造函数时可省略,注意`alterEgo?`中的问号 (?)。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/examples/cli-quickstart/README.md" + "original": "Animation *keyframes* go beyond a simple transition to a more intricate animation\nthat goes through one or more intermediate styles when transitioning between two sets of styles.", + "translation": "通过定义动画的*关键帧*,可以把两组样式之间的简单转场,升级成一种更复杂的动画,它会在转场期间经历一个或多个中间样式。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/animations.md" }, { - "original": "You can create a new hero like this:", - "translation": "可以这样创建新英雄:", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/examples/cli-quickstart/README.md" + "original": "For each keyframe, you specify an *offset* that defines at which point\nin the animation that keyframe applies. The offset is a number between zero,\nwhich marks the beginning of the animation, and one, which marks the end.", + "translation": "每个关键帧都可以被指定一个*偏移量*,用来定义该关键帧将被用在动画期间的哪个时间点。偏移量是一个介于0(表示动画起点)和1(表示动画终点)之间的数组。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/animations.md" }, { - "original": "## Create a form component", - "translation": "## 创建表单组件", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/examples/cli-quickstart/README.md" + "original": "This example adds some \"bounce\" to the enter and leave animations with\nkeyframes:", + "translation": "在这个例子中,我们使用关键帧来为进场和离场动画添加一些“反弹效果”:", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/animations.md" }, { - "original": "An Angular form has two parts: an HTML-based _template_ and a component _class_\nto handle data and user interactions programmatically.\nBegin with the class because it states, in brief, what the hero editor can do.", - "translation": "Angular 表单分为两部分:基于 HTML 的*模板*和组件*类*,用来程序处理数据和用户交互。\n先从组件类开始,是因为它可以简要说明英雄编辑器能做什么。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/examples/cli-quickstart/README.md" + "original": "Note that the offsets are *not* defined in terms of absolute time. They are relative\nmeasures from zero to one. The final timeline of the animation is based on the combination\nof keyframe offsets, duration, delay, and easing.", + "translation": "注意,这个偏移量并*不是*用绝对数字定义的时间段,而是在0到1之间的相对值(百分比)。动画的最终时间线会基于关键帧的偏移量、持续时间、延迟和缓动函数计算出来。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/animations.md" }, { - "original": "Create the following file with the given content:", - "translation": "创建下列文件:", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/examples/cli-quickstart/README.md" + "original": "Defining offsets for keyframes is optional. If you omit them, offsets with even\nspacing are automatically assigned. For example, three keyframes without predefined\noffsets receive offsets `0`, `0.5`, and `1`.", + "translation": "为关键帧定义偏移量是可选的。如果省略它们,偏移量会自动根据帧数平均分布出来。例如,三个未定义过偏移量的关键帧会分别获得偏移量:`0`、`0.5`和`1`。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/animations.md" }, { - "original": "There’s nothing special about this component, nothing form-specific,\nnothing to distinguish it from any component you've written before.", - "translation": "这个组件没有什么特别的地方,没有表单相关的东西,与之前写过的组件没什么不同。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/examples/cli-quickstart/README.md" + "original": "## Parallel animation groups", + "translation": "## 并行动画组(Group)", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/animations.md" }, { - "original": "Understanding this component requires only the Angular concepts covered in previous pages.", - "translation": "只需要前面章节中学过的概念,就可以完全理解这个组件:", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/examples/cli-quickstart/README.md" + "original": "You've seen how to animate multiple style properties at the same time:\njust put all of them into the same `style()` definition.", + "translation": "我们已经知道该如何在同一时间段进行多个样式的动画了:只要把它们都放进同一个`style()`定义中就行了!", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/animations.md" }, { - "original": "* The code imports the Angular core library and the `Hero` model you just created.", - "translation": "这段代码导入了Angular核心库以及我们刚刚创建的`Hero`模型。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/examples/cli-quickstart/README.md" + "original": "But you may also want to configure different *timings* for animations that happen\nin parallel. For example, you may want to animate two CSS properties but use a\ndifferent easing function for each one.", + "translation": "但我们也可能会希望为同时发生的几个动画配置不同的*时间线*。比如,同时对两个CSS属性做动画,但又得为它们定义不同的缓动函数。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/animations.md" }, { - "original": "* The `@Component` selector value of \"hero-form\" means you can drop this form in a parent template with a `` tag.", - "translation": "`@Component`选择器“hero-form”表示可以用``标签把这个表单放进父模板。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/examples/cli-quickstart/README.md" + "original": "For this you can use animation *groups*. In this example, using groups both on\nenter and leave allows for two different timing configurations. Both\nare applied to the same element in parallel, but run independently of each other:", + "translation": "这种情况下就可以用动画*组*来解决了。在这个例子中,我们同时在进场和离场时使用了组,以便能让它们使用两种不同的时间线配置。\n它们被同时应用到同一个元素上,但又彼此独立运行:", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/animations.md" }, { - "original": "* The `templateUrl` property points to a separate file for the template HTML.", - "translation": "`moduleId: module.id`属性设置了基地址,用于从相对模块路径加载`templateUrl`。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/examples/cli-quickstart/README.md" + "original": "One group animates the element transform and width; the other group animates the opacity.", + "translation": "其中一个动画组对元素的`transform`和`width`做动画,另一个组则对`opacity`做动画。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/animations.md" }, { - "original": "* You defined dummy data for `model` and `powers`, as befits a demo.", - "translation": "`templateUrl`属性指向一个独立的 HTML 模板文件。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/examples/cli-quickstart/README.md" + "original": "其中一个动画组对元素的`transform`和`width`做动画,另一个组则对`opacity`做动画。", + "translation": "## Animation callbacks\n## 动画回调", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/animations.md" }, { - "original": "Down the road, you can inject a data service to get and save real data\nor perhaps expose these properties as inputs and outputs\n(see [Input and output properties](guide/template-syntax#inputs-outputs) on the\n[Template Syntax](guide/template-syntax) page) for binding to a\nparent component. This is not a concern now and these future changes won't affect the form.", - "translation": "接下来,我们可以注入一个数据服务,以获取或保存真实的数据,或者把这些属性暴露为输入属性和输出属性(参见[Template Syntax](guide/template-syntax)中的[输入和输出属性](guide/template-syntax#inputs-outputs))来绑定到一个父组件。这不是现在需要关心的问题,未来的更改不会影响到这个表单。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/examples/cli-quickstart/README.md" + "original": "A callback is fired when an animation is started and also when it is done.", + "translation": "当动画开始和结束时,会触发一个回调。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/animations.md" }, { - "original": "* You added a `diagnostic` property to return a JSON representation of the model.\nIt'll help you see what you're doing during development; you've left yourself a cleanup note to discard it later.", - "translation": "我们添加一个`diagnostic`属性,以返回这个模型的 JSON 形式。在开发过程中,它用于调试,最后清理时会丢弃它。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/examples/cli-quickstart/README.md" + "original": "In the keyframes example, you have a `trigger` called `@flyInOut`. You can hook\nthose callbacks like this:", + "translation": "对于例子中的这个关键帧,我们有一个叫做`@flyInOut`的`trigger`。在那里我们可以挂钩到那些回调,比如:", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/animations.md" }, { - "original": "### Why the separate template file?", - "translation": "### 为何分离模板文件?", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/examples/cli-quickstart/README.md" + "original": "The callbacks receive an `AnimationEvent` that contains useful properties such as\n`fromState`, `toState` and `totalTime`.", + "translation": "这些回调接收一个`AnimationTransitionEvent`参数,它包含一些有用的属性,例如`fromState`,`toState`和`totalTime`。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/animations.md" }, { - "original": "Why don't you write the template inline in the component file as you often do elsewhere?", - "translation": "为什么不与我们在其他地方常常做的那样,以内联的方式把模板写在组件文件中呢?", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/examples/cli-quickstart/README.md" + "original": "Those callbacks will fire whether or not an animation is picked up.", + "translation": "无论动画是否实际执行过,那些回调都会触发。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/animations.md" }, { - "original": "There is no \"right\" answer for all occasions. Inline templates are useful when they are short.\nMost form templates aren't short. TypeScript and JavaScript files generally aren't the best place to\nwrite (or read) large stretches of HTML, and few editors help with files that have a mix of HTML and code.", - "translation": "没有什么答案在所有场合都总是“正确”的。当模板足够短的时候,内联形式更招人喜欢。\n但大多数的表单模板都不短。通常,TypeScript 和 JavaScript 文件不是写(读)大型 HTML 的好地方,\n而且没有几个编辑器能对混写的 HTML 和代码提供足够的帮助。\n我们还是喜欢内容清晰、目标明确的短文件,像这个一样。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/examples/cli-quickstart/README.md" + "original": "# Ahead-of-Time Compilation", + "translation": "# 预 (AoT) 编译器", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/aot-compiler.md" }, { - "original": "Form templates tend to be large, even when displaying a small number of fields,\nso it's usually best to put the HTML template in a separate file.\nYou'll write that template file in a moment. First,\nrevise the `app.module.ts` and `app.component.ts` to make use of the new `HeroFormComponent`.", - "translation": "就算是在仅仅显示少数表单项目时,表单模板一般都比较庞大。所以通常最好的方式是将 HTML 模板放到单独的文件中。\n一会儿将编写这个模板文件。在这之前,先退一步,再看看`app.module.ts`和`app.component.ts`,让它们使用新的`HeroFormComponent`。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/examples/cli-quickstart/README.md" + "original": "This cookbook describes how to radically improve performance by compiling _ahead-of-time_ (AOT)\nduring a build process.", + "translation": "本章描述了如何通过在构建期间使用预编译(AOT编译)技术来根本性的提高性能。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/aot-compiler.md" }, { - "original": "## Revise *app.module.ts*", - "translation": "## 修改 *app.module.ts*", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/examples/cli-quickstart/README.md" + "original": "## Overview", + "translation": "## 概览", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/aot-compiler.md" }, { - "original": "`app.module.ts` defines the application's root module. In it you identify the external modules you'll use in the application\nand declare the components that belong to this module, such as the `HeroFormComponent`.", - "translation": "`app.module.ts`定义了应用的根模块。其中标识即将用到的外部模块,以及声明属于本模块中的组件,例如`HeroFormComponent`。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/examples/cli-quickstart/README.md" + "original": "An Angular application consists largely of components and their HTML templates.\nBefore the browser can render the application,\nthe components and templates must be converted to executable JavaScript by the _Angular compiler_.", + "translation": "Angular应用主要包含组件和它们的HTML模板。\n在浏览器可以渲染应用之前,组件和模板必须要被**Angular编译器**转换为可以执行的JavaScript。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/aot-compiler.md" }, { - "original": "Because template-driven forms are in their own module, you need to add the `FormsModule` to the array of\n`imports` for the application module before you can use forms.", - "translation": "因为模板驱动的表单位于它们自己的模块,所以在使用表单之前,需要将`FormsModule`添加到应用模块的`imports`数组中。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/examples/cli-quickstart/README.md" + "original": "Watch compiler author Tobias Bosch explain the Angular Compiler at AngularConnect 2016.", + "translation": "观看编译器作者Tobias Bosch在AngularConnect 2016大会里,对Angular编译器的演讲。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/aot-compiler.md" }, { - "original": "Replace the contents of the \"QuickStart\" version with the following:", - "translation": "把“快速上手”版的文件替换为如下内容:", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/examples/cli-quickstart/README.md" + "original": "You can compile the app in the browser, at runtime, as the application loads, using the **_just-in-time_ (JIT) compiler**.\nThis is the standard development approach shown throughout the documentation.\nIt's great but it has shortcomings.", + "translation": "你可以在浏览器中使用*即时编译器*(Just-in-Time - JIT)在运行期间编译该应用,也就是在应用加载时。\n这是本文档中展示过的标准开发方式。\n它很不错,但是有自己的缺点。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/aot-compiler.md" }, { - "original": "There are three changes:", - "translation": "有三处更改:", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/examples/cli-quickstart/README.md" + "original": "JIT compilation incurs a runtime performance penalty.\nViews take longer to render because of the in-browser compilation step.\nThe application is bigger because it includes the Angular compiler\nand a lot of library code that the application won't actually need.\nBigger apps take longer to transmit and are slower to load.", + "translation": "JIT编译导致运行期间的性能损耗。\n由于需要在浏览器中执行这个编译过程,视图需要花更长时间才能渲染出来。\n由于应用包含了Angular编译器以及大量实际上并不需要的库代码,所以文件体积也会更大。\n更大的应用需要更长的时间进行传输,加载也更慢。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/aot-compiler.md" }, { - "original": "1. You import `FormsModule` and the new `HeroFormComponent`.", - "translation": "导入`FormsModule`和新组件`HeroFormComponent`。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/examples/cli-quickstart/README.md" + "original": "Compilation can uncover many component-template binding errors.\nJIT compilation discovers them at runtime, which is late in the process.", + "translation": "编译可以发现一些组件模板绑定错误。JIT编译在运行时才揭露它们,那样有点太晚了。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/aot-compiler.md" }, { - "original": "1. You add the `FormsModule` to the list of `imports` defined in the `@NgModule` decorator. This gives the application\naccess to all of the template-driven forms features, including `ngModel`.", - "translation": "把`FormsModule`添加到`ngModule`装饰器的`imports`列表中,这样应用就能访问模板驱动表单的所有特性,包括`ngModel`。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/examples/cli-quickstart/README.md" + "original": "The **_ahead-of-time_ (AOT) compiler** can catch template errors early and improve performance\nby compiling at build time.", + "translation": "而**预编译**(AOT)会在构建时编译,这样可以在早期截获模板错误,提高应用性能。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/aot-compiler.md" }, { - "original": "1. You add the `HeroFormComponent` to the list of `declarations` defined in the `@NgModule` decorator. This makes\nthe `HeroFormComponent` component visible throughout this module.", - "translation": "把`HeroFormComponent`添加到`ngModule`装饰器的`declarations`列表中,使`HeroFormComponent`组件在整个模块中可见。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/examples/cli-quickstart/README.md" + "original": "{@a aot-jit}", + "translation": "## _Ahead-of-time_ (AOT) vs _just-in-time_ (JIT)\n## 预编译(AOT) vs 即时编译(JIT)", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/aot-compiler.md" }, { - "original": "If a component, directive, or pipe belongs to a module in the `imports` array, ​_don't_​ re-declare it in the `declarations` array.\nIf you wrote it and it should belong to this module, ​_do_​ declare it in the `declarations` array.", - "translation": "如果某个组件、指令或管道是属于`imports`中所导入的某个模块的,那就_不能再_把它再声明到本模块的`declarations`数组中。\n如果它是你自己写的,并且确实属于当前模块,*才应该*把它声明在`declarations`数组中。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/examples/cli-quickstart/README.md" + "original": "There is actually only one Angular compiler. The difference between AOT and JIT is a matter of timing and tooling.\nWith AOT, the compiler runs once at build time using one set of libraries;\nwith JIT it runs every time for every user at runtime using a different set of libraries.", + "translation": "事实上只有一个Angular编译器,AOT和JIT之间的差别仅仅在于编译的时机和所用的工具。\n使用AOT,编译器仅仅使用一组库在构建期间运行一次;使用JIT,编译器在每个用户的每次运行期间都要用不同的库运行一次。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/aot-compiler.md" }, { - "original": "## Revise *app.component.ts*", - "translation": "## 修改 *app.component.ts*", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/examples/cli-quickstart/README.md" + "original": "## Why do AOT compilation?", + "translation": "## 为什么需要AOT编译?", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/aot-compiler.md" }, { - "original": "`AppComponent` is the application's root component. It will host the new `HeroFormComponent`.", - "translation": "`AppComponent`是应用的根组件,`HeroFormComponent`将被放在其中。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/examples/cli-quickstart/README.md" + "original": "*Faster rendering*", + "translation": "**渲染得更快**", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/aot-compiler.md" }, { - "original": "Replace the contents of the \"QuickStart\" version with the following:", - "translation": "把“快速上手”的版本内容替换成下列代码:", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/examples/cli-quickstart/README.md" + "original": "With AOT, the browser downloads a pre-compiled version of the application.\nThe browser loads executable code so it can render the application immediately, without waiting to compile the app first.", + "translation": "使用AOT,浏览器下载预编译版本的应用程序。\n浏览器直接加载运行代码,所以它可以立即渲染该应用,而不用等应用完成首次编译。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/aot-compiler.md" }, { - "original": "There are only two changes.\nThe `template` is simply the new element tag identified by the component's `selector` property.\nThis displays the hero form when the application component is loaded.\nYou've also dropped the `name` field from the class body.", - "translation": "这里只做了两处修改。\n`template`中只剩下这个新的元素标签,即组件的`selector`属性。这样当应用组件被加载时,就会显示这个英雄表单。\n另外,我们还从类中移除了`name`字段。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/examples/cli-quickstart/README.md" + "original": "*Fewer asynchronous requests*", + "translation": "**需要的异步请求更少**", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/aot-compiler.md" }, { - "original": "## Create an initial HTML form template", - "translation": "## 创建初始 HTML 表单模板", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/examples/cli-quickstart/README.md" + "original": "The compiler _inlines_ external HTML templates and CSS style sheets within the application JavaScript,\neliminating separate ajax requests for those source files.", + "translation": "编译器把外部HTML模板和CSS样式表内联到了该应用的JavaScript中。\n消除了用来下载那些源文件的Ajax请求。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/aot-compiler.md" }, { - "original": "Create the template file with the following contents:", - "translation": "用下列内容新建模板文件:", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/examples/cli-quickstart/README.md" + "original": "*Smaller Angular framework download size*", + "translation": "**需要下载的Angular框架体积更小**", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/aot-compiler.md" }, { - "original": "The language is simply HTML5. You're presenting two of the `Hero` fields, `name` and `alterEgo`, and\nopening them up for user input in input boxes.", - "translation": "这只是一段普通的旧式 HTML 5 代码。这里有两个`Hero`字段,`name`和`alterEgo`,供用户输入。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/examples/cli-quickstart/README.md" + "original": "There's no need to download the Angular compiler if the app is already compiled.\nThe compiler is roughly half of Angular itself, so omitting it dramatically reduces the application payload.", + "translation": "如果应用已经编译过了,自然不需要再下载Angular编译器了。\n该编译器差不多占了Angular自身体积的一半儿,所以,省略它可以显著减小应用的体积。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/aot-compiler.md" }, { - "original": "The *Name* `` control has the HTML5 `required` attribute;\nthe *Alter Ego* `` control does not because `alterEgo` is optional.", - "translation": "*Name* ``控件具有 HTML5 的`required`属性;但 *Alter Ego* ``控件没有,因为`alterEgo`字段是可选的。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/examples/cli-quickstart/README.md" + "original": "*Detect template errors earlier*", + "translation": "**提早检测模板错误**", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/aot-compiler.md" }, { - "original": "You added a *Submit* button at the bottom with some classes on it for styling.", - "translation": "在底部添加个 *Submit* 按钮,它还带一些 CSS 样式类。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/examples/cli-quickstart/README.md" + "original": "The AOT compiler detects and reports template binding errors during the build step\nbefore users can see them.", + "translation": "AOT编译器在构建过程中检测和报告模板绑定错误,避免用户遇到这些错误。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/aot-compiler.md" }, { - "original": "*You're not using Angular yet*. There are no bindings or extra directives, just layout.", - "translation": "**我们还没有真正用到Angular**。没有绑定,没有额外的指令,只有布局。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/examples/cli-quickstart/README.md" + "original": "*Better security*", + "translation": "**更安全**", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/aot-compiler.md" }, { - "original": "In template driven forms, if you've imported `FormsModule`, you don't have to do anything\nto the `` tag in order to make use of `FormsModule`. Continue on to see how this works.", - "translation": "在模板驱动表单中,你只要导入了`FormsModule`就不用对``做任何改动来使用`FormsModule`。接下来你会看到它的原理。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/examples/cli-quickstart/README.md" + "original": "AOT compiles HTML templates and components into JavaScript files long before they are served to the client.\nWith no templates to read and no risky client-side HTML or JavaScript evaluation,\nthere are fewer opportunities for injection attacks.", + "translation": "AOT编译远在HTML模版和组件被服务到客户端之前,将它们编译到JavaScript文件。\n没有模版可以阅读,没有高风险客户端HTML或JavaScript可利用,所以注入攻击的机会较少。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/aot-compiler.md" }, { - "original": "The `container`, `form-group`, `form-control`, and `btn` classes\ncome from [Twitter Bootstrap](http://getbootstrap.com/css/). These classes are purely cosmetic.\nBootstrap gives the form a little style.", - "translation": "`container`、`form-group`、`form-control`和`btn`类来自 [Twitter Bootstrap](http://getbootstrap.com/css/)。纯粹是装饰。\n我们使用 Bootstrap 来美化表单。嘿,一点样式都没有的表单算个啥!", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/examples/cli-quickstart/README.md" + "original": "## Compile with AOT", + "translation": "## 用AOT进行编译", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/aot-compiler.md" }, { - "original": "
\n Angular forms don't require a style library\n
", - "translation": "
\n Angular 表单不需要任何样式库\n
", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/examples/cli-quickstart/README.md" + "original": "Preparing for offline compilation takes a few simple steps.\nTake the Setup as a starting point.\nA few minor changes to the lone `app.component` lead to these two class and HTML files:", + "translation": "AOT编译需要一些简单的准备步骤。我们先从搭建本地开发环境开始。\n只要单独对`app.component`文件的类文件和HTML文件做少量修改就可以了。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/aot-compiler.md" }, { - "original": "Angular makes no use of the `container`, `form-group`, `form-control`, and `btn` classes or\nthe styles of any external library. Angular apps can use any CSS library or none at all.", - "translation": "Angular 不需要`container`、`form-group`、`form-control`和`btn`类,\n或者外部库的任何样式。Angular 应用可以使用任何 CSS 库…… ,或者啥都不用。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/examples/cli-quickstart/README.md" + "original": "Install a few new npm dependencies with the following command:", + "translation": "用下列命令安装少量新的npm依赖:", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/aot-compiler.md" }, { - "original": "To add the stylesheet, open `index.html` and add the following link to the ``:", - "translation": "我们来添加样式表。打开`index.html`,并把下列链接添加到``中:", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/examples/cli-quickstart/README.md" + "original": "You will run the `ngc` compiler provided in the `@angular/compiler-cli` npm package\ninstead of the TypeScript compiler (`tsc`).", + "translation": "你要用`@angular/compiler-cli`包中提供的`ngc`编译器来代替TypeScript编译器(`tsc`)。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/aot-compiler.md" }, { - "original": "## Add powers with _*ngFor_", - "translation": "## 用 ***ngFor*** 添加超能力", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/examples/cli-quickstart/README.md" + "original": "`ngc` is a drop-in replacement for `tsc` and is configured much the same way.", + "translation": "`ngc`是一个`tsc`的高仿替代品,它们的配置方式几乎完全一样。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/aot-compiler.md" }, { - "original": "The hero must choose one superpower from a fixed list of agency-approved powers.\nYou maintain that list internally (in `HeroFormComponent`).", - "translation": "我们的英雄必须从认证过的固定列表中选择一项超能力。\n 这个列表位于`HeroFormComponent`中。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/examples/cli-quickstart/README.md" + "original": "`ngc` requires its own `tsconfig.json` with AOT-oriented settings.\nCopy the original `src/tsconfig.json` to a file called `tsconfig-aot.json` on the project root,\nthen modify it as follows.", + "translation": "`ngc`需要自己的带有AOT专用设置的`tsconfig.json`。\n把原始的`tsconfig.json`拷贝到一个名叫`tsconfig-aot.json`的文件中,然后像这样修改它:", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/aot-compiler.md" }, { - "original": "You'll add a `select` to the\nform and bind the options to the `powers` list using `ngFor`,\na technique seen previously in the [Displaying Data](guide/displaying-data) page.", - "translation": "在表单中添加`select`,用`ngFor`把`powers`列表绑定到列表选项。\n我们在之前的[显示数据](guide/displaying-data)一章中见过`ngFor`。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/examples/cli-quickstart/README.md" + "original": "The `compilerOptions` section is unchanged except for one property.\n**Set the `module` to `es2015`**.\nThis is important as explained later in the [Tree Shaking](guide/aot-compiler#tree-shaking) section.", + "translation": "`compilerOptions`部分只修改了一个属性:**把`module`设置为`es2015`。\n这一点非常重要,我们会在后面的[摇树优化](guide/aot-compiler#tree-shaking)部分解释为什么。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/aot-compiler.md" }, { - "original": "Add the following HTML *immediately below* the *Alter Ego* group:", - "translation": "在 *Alter Ego* 的紧下方添加如下 HTML:", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/examples/cli-quickstart/README.md" + "original": "What's really new is the `ngc` section at the bottom called `angularCompilerOptions`.\nIts `genDir` property tells the compiler\nto store the compiled output files in a new `aot` folder.", + "translation": "`ngc`区真正新增的内容是底部的`angularCompilerOptions`。\n它的`genDir`属性告诉编译器把编译结果保存在新的`aot`目录下。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/aot-compiler.md" }, { - "original": "This code repeats the `
", + "translation": "### none\n ### 没了\n For performance reasons, no comparable pipe exists in Angular. Do all your filtering in the component. If you need the same filtering code in several templates, consider building a custom pipe.", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { - "original": "*Delete* the `{{diagnostic}}` binding at the top as it has served its purpose.", - "translation": "表单顶部的`{{diagnostic}}`绑定已经完成了它的使命,**删除**它。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "### none\n ### 没了\n For performance reasons, no comparable pipe exists in Angular. Do all your filtering in the component. If you need the same filtering code in several templates, consider building a custom pipe.", + "translation": "在Angular中,出于性能的考虑,并没有一个类似的管道。\n 过滤逻辑应该在组件中用代码实现。\n 如果它将被复用在几个模板中,可以考虑构建一个自定义管道。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { - "original": "## Track control state and validity with _ngModel_", - "translation": "## 通过 **ngModel** 跟踪修改状态与有效性验证", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "Converts a JavaScript object into a JSON string. This is useful for debugging.", + "translation": "把一个JavaScript对象转换成一个JSON字符串。这对调试很有用。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { - "original": "Using `ngModel` in a form gives you more than just two-way data binding. It also tells\nyou if the user touched the control, if the value changed, or if the value became invalid.", - "translation": "在表单中使用`ngModel`可以获得比仅使用双向数据绑定更多的控制权。它还会告诉我们很多信息:用户碰过此控件吗?它的值变化了吗?数据变得无效了吗?", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "The Angular `json` pipe does the same thing.", + "translation": "Angular的`json`管道做完全相同的事。\n ", + "translation": "### none\n ### 没了\n For performance reasons, no comparable pipe exists in Angular.\n Instead, use component code to order or sort results. If you need the same ordering or sorting code in several templates, consider building a custom pipe.", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { - "original": "1. Look but don't touch.", - "translation": "查看输入框,但别碰它。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "### none\n ### 没了\n For performance reasons, no comparable pipe exists in Angular.\n Instead, use component code to order or sort results. If you need the same ordering or sorting code in several templates, consider building a custom pipe.", + "translation": "在Angular中,出于性能的考虑,并没有一个类似的管道。\n 排序逻辑应该在组件中用代码实现。\n 如果它将被复用在几个模板中,可以考虑构建一个自定义管道。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { - "original": "1. Click inside the name box, then click outside it.", - "translation": "点击输入框,然后点击输入框外面。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "## Modules/controllers/components", + "translation": "## 模块/控制器/组件", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { - "original": "1. Add slashes to the end of the name.", - "translation": "在名字的末尾添加些斜杠。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "In both AngularJS and Angular, modules help you organize your application into cohesive blocks of functionality.", + "translation": "无论在AngularJS还是Angular中,我们都要借助“模块”来把应用拆分成一些紧密相关的功能块。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { - "original": "1. Erase the name.", - "translation": "删除名字。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "In AngularJS, you write the code that provides the model and the methods for the view in a **controller**.\nIn Angular, you build a **component**.", + "translation": "在AngularJS中,我们在**控制器**中写代码,来为视图提供模型和方法。\n在Angular中,我们创建**组件**。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { - "original": "The actions and effects are as follows:", - "translation": "动作和它对应的效果如下:", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "Because much AngularJS code is in JavaScript, JavaScript code is shown in the AngularJS column.\nThe Angular code is shown using TypeScript.", + "translation": "因为很多AngularJS的代码是用JavaScript写的,所以在AngularJS列显示的是JavaScript代码,而Angular列显示的是TypeScript代码。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { - "original": "动作和它对应的效果如下:", - "translation": "
\n \"控件状态转换\"\n
", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "In AngularJS, an immediately invoked function expression (or IIFE) around controller code\n keeps it out of the global namespace.", + "translation": "在AngularJS中,用立即调用的函数表达式(IIFE)来包裹控制器代码可以让控制器代码不会污染全局命名空间。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { - "original": "You should see the following transitions and class names:", - "translation": "我们会看到下列转换及其类名:", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "### none", + "translation": "### 没了", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { - "original": "The `ng-valid`/`ng-invalid` pair is the most interesting, because you want to send a\nstrong visual signal when the values are invalid. You also want to mark required fields.\nTo create such visual feedback, add definitions for the `ng-*` CSS classes.", - "translation": "(`ng-valid` | `ng-invalid`)这一对是我们最感兴趣的。当数据变得无效时,我们希望发出强力的视觉信号,\n还想要标记出必填字段。可以通过加入自定义 CSS 来提供视觉反馈。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "This is a nonissue in Angular because ES 2015 modules \n handle the namespacing for you.", + "translation": "在Angular中我们不用担心这个问题,因为使用ES 2015的模块,模块会替我们处理命名空间问题。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { - "original": "*Delete* the `#spy` template reference variable and the `TODO` as they have served their purpose.", - "translation": "**删除**模板引用变量`#spy`和`TODO`,因为它们已经完成了使命。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "For more information on modules, see the [Modules](guide/architecture#modules) section of the \n [Architecture Overview](guide/architecture).", + "translation": "要了解关于模块的更多信息,参见[架构概览](guide/architecture)中的[模块](guide/architecture#modules)部分。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { - "original": "## Add custom CSS for visual feedback", - "translation": "## 添加用于视觉反馈的自定义 CSS", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "### Angular modules", + "translation": "### Angular模块", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { - "original": "You can mark required fields and invalid data at the same time with a colored bar\non the left of the input box:", - "translation": "可以在输入框的左侧添加带颜色的竖条,用于标记必填字段和无效输入:", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "In AngularJS, an Angular module keeps track of controllers, services, and other code. \n The second argument defines the list of other modules that this module depends upon.", + "translation": "在AngularJS中,Angular模块用来对控制器、服务和其它代码进行跟踪。第二个参数定义该模块依赖的其它模块列表。\n
", + "translation": "### Controller registration\n### 控制器注册 \n angular\n .module(\"movieHunter\")\n .controller(\"MovieListCtrl\",\n [\"movieService\",\n MovieListCtrl]);\n ", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { - "original": "When the user deletes the name, the form should look like this:", - "translation": "当用户删除姓名时,应该是这样的:", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "AngularJS has code in each controller that looks up an appropriate Angular module\n and registers the controller with that module.", + "translation": "在AngularJS中,在每个控制器中都有一些代码,用于找到合适的Angular模块并把该控制器注册进去。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { - "original": "当用户删除姓名时,应该是这样的:", - "translation": "
\n \"必须填写姓名\"\n
", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "The first argument is the controller name. The second argument defines the string names of\n all dependencies injected into this controller, and a reference to the controller function.", + "translation": "第一个参数是控制器的名称,第二个参数定义了所有将注入到该控制器的依赖的字符串名称,以及一个到控制器函数的引用。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { - "original": "To achieve this effect, extend the `` tag with the following:", - "translation": "要达到这个效果,在``标签中添加:", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "### Component decorator", + "translation": "### 组件装饰器", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { - "original": "* A [template reference variable](guide/template-syntax#ref-vars).", - "translation": "[模板引用变量](guide/template-syntax#ref-vars)", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "Angular adds a decorator to the component class to provide any required metadata.\n The `@Component` decorator declares that the class is a component and provides metadata about\n that component such as its selector (or tag) and its template.", + "translation": "在Angular中,我们往组件类上添加了一个装饰器,以提供任何需要的元数据。\n `@Component`装饰器把该类声明为组件,并提供了关于该组件的元数据,比如它的选择器(或标签)和模板。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { - "original": "* The \"*is required*\" message in a nearby `
`, which you'll display only if the control is invalid.", - "translation": "“is required”消息,放在邻近的`
`元素中,只有当控件无效时,才显示它。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "This is how you associate a template with logic, which is defined in the component class.", + "translation": "这就是把模板关联到代码的方式,它定义在组件类中。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { - "original": "Here's an example of an error message added to the _name_ input box:", - "translation": "这个例子中我们把一条错误信息添加到了_name_输入框中:", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "For more information, see the [Components](guide/architecture#components) \n section of the [Architecture Overview](guide/architecture) page.", + "translation": "要了解关于模板的更多信息,参见[架构概览](guide/architecture)中的[组件](guide/architecture#components)部分。", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { - "original": "You need a template reference variable to access the input box's Angular control from within the template.\nHere you created a variable called `name` and gave it the value \"ngModel\".", - "translation": "模板引用变量可以访问模板中输入框的 Angular 控件。\n这里,创建了名叫`name`的变量,并且赋值为 \"ngModel\"。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "### Controller function", + "translation": "### 控制器函数", + "sourceFile": "/Users/twer/private/GDE/content-1/guide/ajs-quick-reference.md" }, { - "original": "Why \"ngModel\"?\nA directive's [exportAs](api/core/Directive) property\ntells Angular how to link the reference variable to the directive.\nYou set `name` to `ngModel` because the `ngModel` directive's `exportAs` property happens to be \"ngModel\".", - "translation": "为什么是 “ngModel”?\n指令的 [exportAs](api/core/Directive) 属性告诉 Angular 如何链接模板引用变量到指令。\n这里把`name`设置为`ngModel`是因为`ngModel`指令的`exportAs`属性设置成了 “ngModel”。", - "sourceFile": "/Users/twer/private/GDE/angular-cn/aio/content/_fragments/glossary-t2.md" + "original": "In AngularJS, you write the code for the model and methods in a controller function.", + "translation": "在Angular1中,我们在控制器函数中写模型和方法的代码。\n