Templates AngularJS表达式在IE8的style属性中不起作用
在style属性上使用这样的表达式在Chrome上有效,但在IE8上不起作用Templates AngularJS表达式在IE8的style属性中不起作用,templates,internet-explorer-8,expression,angularjs,Templates,Internet Explorer 8,Expression,Angularjs,在style属性上使用这样的表达式在Chrome上有效,但在IE8上不起作用 style="width:{{progress}}%" (要测试它,请在文本框中键入一个数字) 有解决这个问题的方法吗?我是这样做的: 在控制器中: $scope.getStyle = function(progress){ return { width: progress + "%" } } 在HTML中: <div class="progbar" ng-style="get
style="width:{{progress}}%"
(要测试它,请在文本框中键入一个数字)
有解决这个问题的方法吗?我是这样做的: 在控制器中:
$scope.getStyle = function(progress){
return {
width: progress + "%"
}
}
在HTML中:
<div class="progbar" ng-style="getStyle(progress)"></div>
试试看
由于某种原因,我不得不使用IE
ng-attr-style="{{METHOD_TO_RETURN_SOME_STYLE()}}"
虽然我的是在ng repeat下的指令中。如果有人使用px而不是%,你必须使用这个
ng-style="{ width: progress + \'px\' }"
我必须使用
ngattr样式
(尽管我不需要使用函数)
这是一个关于这个问题的解决方案。您可能想尝试使用“ng style”来代替。解决方案是ng style=“{width:propertyInScope+'%}”,这是一个JSFIDLE,该解决方案在IE8上运行正常,甚至在IE11中也不起作用。我认为这对theOP和其他用户更有帮助,当你为你的想法添加一些解释时,谢谢!这是最好的答案。我需要在Angular 1.5的css属性周围加上单引号,比如:
ng style=“{'width':progress+'%}”
ng-style="{ width: progress + \'px\' }"
<div ng-attr-style="width: {{value}}%"></div>