[英]Angular 2 html directives and attribute directives
I'm new to Angular 2. 我是Angular 2的新手。
Can someone please explain the difference between the html directives and attribute directives
? 有人可以解释
html directives and attribute directives
之间的区别吗? Why are they both needed? 为什么都需要它们?
Example: 例:
<rating [rate]="rate" (rate-change)="onUpdate($event)"></rating>
So: 所以:
rating
is what i call "html directive" but I'm not sure what it's for? rating
是我所谓的“ html指令”,但是我不确定它的用途是什么?
[rate]
is an attribute directive that sets component property named "rate". [rate]
是一个属性指令,用于设置名为“ rate”的组件属性。
(rate-change)
is an attribute directive that calls a component method called rateChange
. (rate-change)
是一个属性指令,该指令调用名为rateChange
的组件方法。
Any other types of directives
? 还有其他类型的
directives
吗?
html directives are for managing dom elements like creating elements. html指令用于管理dom元素,例如创建元素。 attribute directives modify properties of elements.
属性指令修改元素的属性。 so angular could create several divs, then later change a div's text.
因此angular可以创建多个div,然后再更改div的文本。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.