@title
模板语法
@intro
学习如何写模板来显示数据,以及在数据绑定的帮助下响应用户事件。
@description
The Angular application manages what the user sees and can do, achieving this through the interaction of a
component class instance (the *component*) and its user-facing template.
Angular 应用管理着用户之所见和所为,并通过 Component 类的实例(*组件*)和面向用户的模板来与用户交互。
You may be familiar with the component/template duality from your experience with model-view-controller (MVC) or model-view-viewmodel (MVVM).
In Angular, the component plays the part of the controller/viewmodel, and the template represents the view.
从使用模型-视图-控制器 (MVC) 或模型-视图-视图模型 (MVVM) 的经验中,很多开发人员都熟悉了组件和模板这两个概念。
在 Angular 中,组件扮演着控制器或视图模型的角色,模板则扮演视图的角色。
{@a toc}
### Contents
### 目录
This guide covers the basic elements of the Angular template syntax, elements you'll need to construct the view:
本章涵盖了Angular模板语法中的基本元素,你在构建视图时会用到它们:
* [HTML in templates](guide/template-syntax#html)
[模板中的HTML](guide/template-syntax#html)
* [Interpolation ( {{...}} )](guide/template-syntax#interpolation)
[插值表达式( {{...}} )](guide/template-syntax#interpolation)
* [Template expressions](guide/template-syntax#template-expressions)
[模板表达式](guide/template-syntax#template-expressions)
* [Template statements](guide/template-syntax#template-statements)
[模板语句](guide/template-syntax#template-statements)
* [Binding syntax](guide/template-syntax#binding-syntax)
[绑定语法](guide/template-syntax#binding-syntax)
* [Property binding ( [property] )](#property-binding)
[属性 (property) 绑定 ( [property] )](#property-binding)
* [Attribute, class, and style bindings](guide/template-syntax#other-bindings)
[属性、类和样式绑定](guide/template-syntax#other-bindings)
* [Event binding ( (event) )](guide/template-syntax#event-binding)
[事件绑定 ( (event) )](guide/template-syntax#event-binding)
* [Two-way data binding ( [(...)] )](#two-way)
[双向绑定 ( [(...)] )](#two-way)
* [Built-in directives](guide/template-syntax#directives)
[内置指令](guide/template-syntax#directives)
* [Built-in attribute directives](guide/template-syntax#attribute-directives)
[内置属性型指令](guide/template-syntax#attribute-directives)
* [NgClass](guide/template-syntax#ngClass)
* [NgStyle](guide/template-syntax#ngStyle)
* [NgModel ([(ngModel)]) ](#ngModel)
* [Built-in structural directives](guide/template-syntax#structural-directives)
[内置结构型指令](guide/template-syntax#structural-directives)
* [NgIf](guide/template-syntax#ngIf)
* [NgFor](guide/template-syntax#ngFor)
* [Template input variables](guide/template-syntax#template-input-variables)
[模板输入变量](guide/template-syntax#template-input-variables)
* [Microsyntax](guide/template-syntax#microsyntax)
[微语法](guide/template-syntax#microsyntax)
* [The NgSwitch directives](guide/template-syntax#ngSwitch)
[NgSwitch指令](guide/template-syntax#ngSwitch)
* [Template reference variables( #var )](guide/template-syntax#ref-vars)
[模板引用变量( #var )](guide/template-syntax#ref-vars)
* [Input and output properties( @Input and @Output )](guide/template-syntax#inputs-outputs)
[输入输出属性( @Input and @Output )](guide/template-syntax#inputs-outputs)
* [Template expression operators](guide/template-syntax#expression-operators)
[模板表达式操作符](guide/template-syntax#expression-operators)
* [pipe( | )](guide/template-syntax#pipe)
[管道](guide/template-syntax#pipe)
* [safe navigation operator (?.)](guide/template-syntax#safe-navigation-operator)
[安全导航操作符 (?.)](guide/template-syntax#safe-navigation-operator)
The