I have the following code which works great:
<div class="progress progress-striped active">
<div class="progress-bar progress-bar-success" style="width: {{(p.availableIpAddressCount/p.totalIpAddressCount)*100|number:0}}%;background-color: #5cb85c">
{{(p.availableIpAddressCount/p.totalIpAddressCount)*100|number:0}}
</div>
</div>
However, as you can see, I am repeating {{(p.availableIpAddressCount/p.totalIpAddressCount)*100|number:0}}
alot and I therefore would like to assign it to angular variable. I would also like to do an NG-switch on the result. This is what I have tried
<div class="progress progress-striped active" ng-init = "barPercentage= {{(p.availableIpAddressCount/p.totalIpAddressCount)*100|number:0}}">
<div ng-switch="barPercentage">
<div ng-switch-when=">=0" class="progress-bar progress-bar-success" style="width: {{barPercentage}}%;background-color: #5cb85c">
{{(p.availableIpAddressCount/p.totalIpAddressCount)*100|number:0}}
</div>
</div>
</div>
However this doesn't work at all but I'm unsure why. I get no errors in the console.
Any ideas?
ng-init = "barPercentage=(p.availableIpAddressCount/p.totalIpAddressCount)*100|number:0"
|number:0
inside ng-int and try excluding{{}}
. working sample here jsfiddle.net/U3pVM/29446 . let me update if any issue