Skip to content Skip to sidebar Skip to footer

Angularjs Bug In Ie With Style Vs Ng-style

I'm using Angular JS v1.1.5, and found an interesting IE-related issue. In IE 9, 10, 11 and Edge, the following does not seem to work, even though it works fine in Chrome:

Solution 1:

When IE 9 & 10 tries to render that HTML, it basically removes the invalid HTML found on HTML to be parse.

So having style="display: {{'block'}}" consider as invalid html, because it has unknown {{}} syntax & it make that attribute rendered as style=""


Other than having ng-style there you could use ng-attr-* directive like below

<divng-attr-style="{{'width: '+ progress.percent() +'%;'}}"></div>

which will create style attribute when progress.percent() value does changed.

For more information look at this old logged github issue

How style attribute become ""?

Solution 2:

the problem also happens on edge. just write like this

[ngStyle]="{'width.px': 20}"

Post a Comment for "Angularjs Bug In Ie With Style Vs Ng-style"