[英]Problems styling HTML in Angular templates with IE
在 Internet Explorer 中對我的數據數組執行 ng-repeat 時,我在設置元素樣式時遇到問題。 在 Safari、Chrome、Firefox 中一切正常,但出於某種原因,IE 不喜歡我做事的方式。
我正在為您將在下面看到的 ng-repeat 使用自定義過濾器
.filter('range', function() {return function(input, total) {total = parseInt(total);for (var i=0; i<total; i++)input.push(i);return input; };})
基本上, ng-style
中的任何內容都不會在 IE 中翻譯。
<div ng-repeat="key in [] | range:documentData.info.pages">
<div ng-if="(key+1) <= documentData.info.pages" ng-style="width:{{ documentData.style.width }}px;height:{{ documentData.style.height }}">
<div class="formBackground" ng-style="background-image:url('/images/templates/{{ documentData.info.uid }}/{{ documentData.info.id }}/{{ (key+1) }}.png')">
Stuff
</div>
</div>
</div>
您的問題可能是由於您用來設置寬度和高度的字符串語法引起的。 而是嘗試使用對象文字語法,即{width:widthProp, height:heightProp}
。
IE
ng-style="{width:documentData.style.width, height: documentData.style.height }"
和
ng-style="{'background-image':'url(/images/templates/{{documentData.info.uid}}/{{documentData.info.id}}/{{(key+1)}}.png)'}"
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.