我在NgRepeat中显示一个条形图,并使用值frecuency显示条形图的宽度(百分比)。据我所见,IE9-10不喜欢这个部分:style="width:{{type.frecuency}}%;"
<div class="drp" ng-repeat="type in weeks">
<div style="width:{{type.frecuency}}%;" class="percentBar">
<span ng-if="type.frecuency > 14">{{type.frecuency}}%</span>
</div>
</div>这是IE的角度问题,还是我的代码的问题。谢谢
我知道我可以创建一个类,但是修改样式属性更快。
解决方案:ng-style="setBarWidth(type.frecuency);"
scope.setBarWidth = function(width) {
return {width: width+'%'};
};发布于 2014-07-18 13:04:39
当对各种HTML属性使用派生值时,最好使用提供的角指令来完成。它们确保浏览器看到希望它看到的值,而不是绑定语法(在您的例子中是{{type.frecuency}})。
在这里,应该使用ngStyle指令。
<div class="drp" ng-repeat="type in weeks">
<div ng-style="width:{{type.frecuency}}%;" class="percentBar">
<span ng-if="type.frecuency > 14">{{type.frecuency}}%</span>
</div>
</div>对于许多其他HTML属性也有类似的指令,请参阅文档获得完整列表。
https://stackoverflow.com/questions/24825075
复制相似问题