Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Problems styling HTML in Angular templates with IE

I am having trouble styling my elements while doing an ng-repeat of my data array in Internet Explorer. Everything works fine in Safari, Chrome, Firefox, but for some reason IE is not liking the way I am doing things.

I am using a custom filter for the ng-repeat that you'll see below

.filter('range', function() {return function(input, total) {total = parseInt(total);for (var i=0; i<total; i++)input.push(i);return input; };})

Basically, anything inside ng-style do not get translated in 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>  
like image 511
bryan Avatar asked Mar 25 '26 03:03

bryan


1 Answers

Your issue might be due to the string syntax that you are using to set width and height. Instead try using object literal syntax, i.e {width:widthProp, height:heightProp}.

i.e

ng-style="{width:documentData.style.width, height: documentData.style.height }"

and

ng-style="{'background-image':'url(/images/templates/{{documentData.info.uid}}/{{documentData.info.id}}/{{(key+1)}}.png)'}"
like image 135
PSL Avatar answered Mar 26 '26 17:03

PSL



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!