Search code examples
htmlcssangularjsng-style

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.


Solution

  • Just try this:

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