私はこのようにHTMLを設定しました
<div.... repeats in a loop... >
....
<div ng-init="setWidthOfTimeLine(machine)" style="height:2px;" class="background-grey" >
<div ng-style="setWidthOfTime"></div>
</div>
</div>
私のコントローラーには次のようなものがあります:
$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);
}
コンソールで適切な CSS が生成されていることはわかりますが。それはDOMに適用されていません。私が見逃しているアイデアはありますか?
コンソール:
Object {background: "green", width: "12.5%"}
Object {background: "green", width: "25%"}
Object {background: "green", width: "25%"}
Object {background: "green", width: "37.5%"}
編集: setWidthOfTime 変数で高さを設定することで問題の半分を修正しましたが、現在はすべての幅の値に対して最後の値 (37.5%) を使用しています。