Sulu.MeanStack Sulu.MeanStack - 9 months ago 44
AngularJS Question

Set style for a div using angular Scope value

I have a horizontal div to show the percent of some activity. I have one outer div with

and one inner div. I have to fill the inner div with background color based on percentage value obtained from the controller, but my problem is that percentage value is in
variable percentage.

My code is below:

<div class="outerDiv">
<div class="innerDiv" style="'width':{{percentage}}"></div>

is my scope value. But the above code is not working fine so my need is that, I have to set style for div using scope value.plz help


You can use ng-style="{'width' : width}

In your controller:

$scope.width = '50%';