I have my HTML set up like this
<div.... repeats in a loop... >
....
<div ng-init="setWidthOfTimeLine(machine)" style="height:2px;" class="background-grey" >
<div ng-style="setWidthOfTime"></div>
</div>
</div>
and in my controller I have something like this:
$scope.setWidthOfTimeLine = function(machine){
var length = (machine.machineStatus).length - 1;
var widthGreen = (length/8) *100;
$scope.setWidthOfTime = {
background : "green",
width : widthGreen + '%',
height : '2px'
}
console.log($scope.setWidthOfTime);
}
Although I can see proper CSS being generated on the console. It is not being applied to the DOM, any ideas what I am missing?
Console:
Object {background: "green", width: "12.5%"}
Object {background: "green", width: "25%"}
Object {background: "green", width: "25%"}
Object {background: "green", width: "37.5%"}
EDIT : Fixed half the issue by setting height in the setWidthOfTime variable, but now it is taking the last value(37.5%) for all the width values.