Reputation: 5733
I have the following Javascript objects:
There are two properties of this objects: pesonalColor and personRoleColor I have a flag called vm.colorSwitch with which I will switch the color of the span below. With personalColor it works fine but I don't know how to bring in personRoleColor to switch between the colors.
Thanks a lot for your help!
<span ng-repeat="myObject in myObjects" style="width:{{myObject.percentage}}%; background:{{myObject.personalColor}}" class="progress-bar" />
Upvotes: 2
Views: 34
Reputation: 4538
ngStyle allows programatic use of the style attribute.
<span ng-style="{
background: vm.colorSwitch ? myObject.personalColor : myObject.personRoleColor,
width: myObject.percentage + '%'
}" ...></span>
Upvotes: 2