樣式屬性內工作的樣式屬性適用於Chrome,但在IE8AngularJS表達不是IE8
style="width:{{progress}}%"
http://jsfiddle.net/5VDMD/12/(不工作,以測試它,請在文本框中鍵入一個數字使用像這樣的表達)
針對此問題的任何解決方法?
樣式屬性內工作的樣式屬性適用於Chrome,但在IE8AngularJS表達不是IE8
style="width:{{progress}}%"
http://jsfiddle.net/5VDMD/12/(不工作,以測試它,請在文本框中鍵入一個數字使用像這樣的表達)
針對此問題的任何解決方法?
我做了工作方式:
控制器:
$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\' }"
我認爲這對於更多用戶來說會更有幫助,當你爲你的內涵添加一些解釋 – reporter
我不得不使用ng-attr-style
(雖然我沒有需要使用的功能)。
<div ng-attr-style="width: {{value}}%"></div>
這是關於此問題的github discussion。
您可能想嘗試使用'ng-style'。 – Tosh
解決方案是ng-style =「{width:propertyInScope +'%'}」感謝David https://groups.google.com/forum/?fromgroups=#!topic/angular/Bb6087Gv284 – user1877925
這裏是jsfiddle在IE8上工作正常的解決方案http://jsfiddle.net/5VDMD/15/ – user1877925