Javascript 在IE9和IE10中,不能解析样式属性中的模板{{value}}

Javascript 在IE9和IE10中,不能解析样式属性中的模板{{value}},javascript,angularjs,internet-explorer,internet-explorer-9,Javascript,Angularjs,Internet Explorer,Internet Explorer 9,我在NgRepeat中显示一个条列表,并使用值frecuency以百分比形式显示条的宽度。从我所看到的IE9-10不喜欢这个部分:style=“width:{{type.frecuency}}%;” 当为各种HTML属性使用派生值时,最好使用提供的Angular指令。它们确保浏览器看到的是您希望它看到的值,而不是绑定语法(在您的例子中是{{type.frecuency}}) 此处应使用ngStyle指令 <div class="drp" ng-repeat="type in weeks"&

我在NgRepeat中显示一个条列表,并使用值
frecuency
以百分比形式显示条的宽度。从我所看到的IE9-10不喜欢这个部分:
style=“width:{{type.frecuency}}%;”


当为各种HTML属性使用派生值时,最好使用提供的Angular指令。它们确保浏览器看到的是您希望它看到的值,而不是绑定语法(在您的例子中是
{{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>

{{type.frecuency}}}%

对于许多其他HTML属性也有类似的指令,请参见完整列表。

它是否适用于
ng style
?+1 ivami,尝试使用ng style谢谢大家!我用它工作:
ng style=“setBarWidth(type.frecuency);”
实际上
ng style=“width:{{type.frecuency}}%;“
它在任何浏览器中都不工作,因为angular只会生成
ng style=“width:73.13%;”
如果没有
style
属性,您应该向ngStyle传递一个对象,即:
ng style=”{width:type.frequency}“
。这似乎很有效。当然,您也可以在其他地方的代码中定义对象,例如
$scope.styles={width:type.frequency};
,在视图中只需执行
ng style=“styles”
     scope.setBarWidth = function(width) {
        return {width: width+'%'}; 
     };
<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>