1

I got a situation where I loop trough an array of colors and output a hex-value (through angular) into the style attribute

<p class="colors">
    <span ng-repeat="color in product.colors" class="product-color" title="{{ color.title }}" style="background-color: #{{ color.hex }};"></span>
</p>

For some reason, IE8 and IE9 doesn't recognize the background color. All I get is a element without the style attribute, but all the other attributes are there. I have triple checked the values for the variables and they are all there, and it works in Chrome/FF/Opera/Safari.

Output in IE8/9

<span title="White" class="product-color ng-scope" ng-repeat="color in product.colors">

Output in Chrome

<span ng-repeat="color in product.colors" class="product-color ng-scope" style="background-color: #FFFFFF;" title="Vit"></span>

What shall I do to make IE recognize the style attribute?

1
  • 1
    Have you tried ng-style? Commented Oct 30, 2013 at 8:38

1 Answer 1

3

Use ng-style instead of style - IE is removing the attribute before Angular is parsing/compiling the HTML.

http://docs.angularjs.org/api/ng.directive:ngStyle

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.