Angular2表达式+ jquery

时间:2016-10-03 10:03:12

标签: angular

我有以下表达式,它有效:

<div class="circle" data-value="0.8">%</div>

当我尝试将属性绑定到它时:

[data-value]="result/100"

我收到以下错误:

Can't bind to 'data-value' since it isn't a known property of 'div'.

为什么以及如何修复它?

1 个答案:

答案 0 :(得分:4)

<div class="circle" [data-value]="result/100">%</div>更改为

<div class="circle" [attr.data-value]="result/100">%</div>

<div class="circle" attr.data-value="{{result/100}}">%<div>