<\/script>')

NG style not updating dynamically

I use ng-style to dynamically change the color of an HTML element.

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

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

+4
source share
2 answers

Just try the following:

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

Try the following:

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

Source: https://habr.com/ru/post/1611606/


All Articles