不能绑定到“ aria-valuenow”,因为它不是“ div”的已知属性

下面的代码有什么问题吗? 当我试图将一个表达式赋给一个元素时,

<div class="progress-bar progress-bar-striped active" role="progressbar"
aria-valuenow="{{MY_PREC}}" aria-valuemin="0" aria-valuemax="100" >
{{MY_PREC}}
</div>

也被当作

[aria-valuenow]={{MY_PREC}}

好像从 RC5就开始了

有什么想法吗?

47782 次浏览

Angular2 binding is property binding by default. There is no aria-valuenow property on div if there is no directive or component applied that has such an @Input()

Use instead explicit attribute binding

attr.aria-valuenow="\{\{MY_PREC}}"

or

[attr.aria-valuenow]="MY_PREC"

Have you implement the new ngModule stuff ?

If so, the order of declarations has an impact on how the application should work. Maybe you should try to declare your directives in another order

In .ts file:

public MY_PREC = '55';

In .html file:

<div class="progress-bar progress-bar-striped active" role="progressbar"
[attr.aria-valuenow]="MY_PREC" [style.width]="MY_PREC+'%'" aria-valuemin="0" aria-valuemax="100" >
\{\{MY_PREC}}
</div>

ng-style="{width: MY_PREC+ '%'}" you can dynamically change the progress inside progress bar inside progress bar tag