block includes
include ../_util-fns
//- The docs standard h4 style uppercases, making code terms unreadable. Override it.
style.
h4 {font-size: 17px !important; text-transform: none !important;}
.syntax { font-family: Consolas, 'Lucida Sans', Courier, sans-serif; color: black; font-size: 85%; }
h4 .syntax { font-size: 100%; }
:marked
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
:marked
### Contents
### 目录
This guide covers the basic elements of the Angular template syntax, elements you'll need to construct the view:
本章涵盖了Angular模板语法中的基本元素,你在构建视图时会用到它们:
* [HTML in templates](#html)
[模板中的HTML](#html)
* [Interpolation ( {{...}} )](#interpolation)
[插值表达式( {{...}} )](#interpolation)
* [Template expressions](#template-expressions)
[模板表达式](#template-expressions)
* [Template statements](#template-statements)
[模板语句](#template-statements)
* [Binding syntax](#binding-syntax)
[绑定语法](#binding-syntax)
* [Property binding ( [property] )](#property-binding)
[属性 (property) 绑定 ( [property] )](#property-binding)
* [Attribute, class, and style bindings](#other-bindings)
[属性、类和样式绑定](#other-bindings)
* [Event binding ( (event) )](#event-binding)
[事件绑定 ( (event) )](#event-binding)
* [Two-way data binding ( [(...)] )](#two-way)
[双向绑定 ( [(...)] )](#two-way)
* [Built-in directives](#directives)
[内置指令](#directives)
* [Built-in attribute directives](#attribute-directives)
[内置属性型指令](#attribute-directives)
* [NgClass](#ngClass)
* [NgStyle](#ngStyle)
* [NgModel ([(ngModel)]) ](#ngModel)
* [Built-in structural directives](#structural-directives)
[内置结构型指令](#structural-directives)
* [NgIf](#ngIf)
* [NgFor](#ngFor)
* [Template input variables](#template-input-variables)
[模板输入变量](#template-input-variables)
* [Microsyntax](#microsyntax)
[微语法](#microsyntax)
* [The NgSwitch directives](#ngSwitch)
[NgSwitch指令](#ngSwitch)
* [Template reference variables( #var )](#ref-vars)
[模板引用变量( #var )](#ref-vars)
* [Input and output properties( @Input and @Output )](#inputs-outputs)
[输入输出属性( @Input and @Output )](#inputs-outputs)
* [Template expression operators](#expression-operators)
[模板表达式操作符](#expression-operators)
* [pipe( | )](#pipe)
[管道](#pipe)
* [safe navigation operator (?.)](#safe-navigation-operator)
[安全导航操作符 (?.)](#safe-navigation-operator)
The
demonstrates all of the syntax and code snippets described in this guide.
演示了本章中描述的所有语法和代码片段。
.l-hr
a#html
:marked
## HTML in templates
## 模板中的HTML
HTML is the language of the Angular template.
Almost all HTML syntax is valid template syntax.
The `