[2019-11-22] components and templates - display data

Interpolation expression display component properties

{{title}}

Use * ngFor

Use * ngIf

Create data model classes to construct data

 

Template syntax

<Script> element is ignored, in order to prevent script injection attack risk

<Html> <body> all the elements <base> element in the HTML Angular invalid with effect are the same

Interpolation and Template expressions

Interpolation allows you to calculate the combined string element between the HTML tag  <P> {{}} title </ P>

And text within the property assignment statement, <div> <IMG the src = "{} {} itemImageUrl" > </ div>

Template expressions are used to find these strings for you

1, the interpolation expression {{...}}

In brackets is a template expression

 

 Angular expression evaluations of all the braces, the conversion result of the evaluation to a string, and connect them with the adjacent surface of the string amount. Finally, the entire assembly out of the interpolation result is assigned to an element or attribute instruction

{} {} Symbols of this modification are also supported:

 

 

 

2, Template expressions

[property]="expression"

3, expression context

Expression context may comprise an object other than the component

For example, the template input variables: hero

 

Template reference variables: heroName

 

Expression by the template context variable is a variable, the context variable instruction, members of the assembly of superposition, if the variable name references exist in more than one namespace, the template variable is the highest priority, followed by command of context variable, and finally a member of the assembly

Template expressions can not reference anything in the global namespace, such as window or document, they can not call console.log or Math.max. Can only refer to members of the expression context

4. Expressions Guide

Templates statement

模板语句出现在=号右侧的引号中 (event) = "statement"

语句上下文

和表达式一样,语句只能引用语句上下文中 -- 通常是正在绑定事件的那个组件实例

典型的语句上下文就是当前组件的实例

语句上下文可以引用模板自身上下文中的属性

 

 

Guess you like

Origin www.cnblogs.com/QQ-lala/p/11913620.html