【问题标题】:Angular 2 html directives and attribute directivesAngular 2 html 指令和属性指令
【发布时间】:2016-08-14 23:49:13
【问题描述】:

我是 Angular 2 的新手。

有人能解释一下html directives and attribute directives 之间的区别吗?为什么它们都需要?

示例:

<rating [rate]="rate" (rate-change)="onUpdate($event)"></rating>

所以:

rating 就是我所说的“html 指令”,但我不确定它是干什么用的?

[rate] 是一个属性指令,用于设置名为“rate”的组件属性。

(rate-change) 是一个属性指令,它调用称为rateChange 的组件方法。

任何其他类型的directives

【问题讨论】:

  • 我的意思是html directives and attribute directives之间的区别

标签: javascript html angular


【解决方案1】:

html 指令用于管理 dom 元素,例如创建元素。属性指令修改元素的属性。所以 Angular 可以创建多个 div,然后再更改一个 div 的文本。

【讨论】:

  • 在上面的例子中?为什么会有<rating>这个翻译成什么?
猜你喜欢
  • 1970-01-01
  • 2016-11-09
  • 2018-01-17
  • 1970-01-01
  • 2013-10-17
  • 1970-01-01
  • 2018-09-17
  • 2016-09-26
  • 2023-03-27
相关资源
最近更新 更多