user5349506
user5349506

Reputation:

ng-style not getting updated dynamically

I'm using ng-style to change the color of HTML element dynamically.

<i class="fa fa-circle" ng-style='{color: "{{getColor()}}"}'></i>

where getColor() function returns the color to be changed and it can return different colors based upon usecase. For the first time everything is working fine but when getColor() returns different color later, it does not update the color of HTML element.

Upvotes: 4

Views: 1852

Answers (2)

Rohit Rai
Rohit Rai

Reputation: 286

Just try this:

<i class="fa fa-circle" ng-style="{color: getColor()}"></i>

Upvotes: 0

Artless
Artless

Reputation: 4568

Try this:

<i class="fa fa-circle" ng-style="{color: getColor()}"></i>

Upvotes: 2

Related Questions