gpt4 book ai didi

css - AngularJS 样式设置背景

转载 作者:行者123 更新时间:2023-11-28 11:32:52 25 4
gpt4 key购买 nike

我有以下 Javascript 对象:

My Objects look like this

这个对象有两个属性:pesonalColorpersonRoleColor我有一个名为 vm.colorSwitch 的标志,我将使用它来切换下方跨度的颜色。使用 personalColor 效果很好,但我不知道如何引入 personRoleColor 来在颜色之间切换。

非常感谢您的帮助!

<span ng-repeat="myObject in myObjects" style="width:{{myObject.percentage}}%; background:{{myObject.personalColor}}" class="progress-bar" />

最佳答案

ngStyle允许以编程方式使用样式属性。

<span ng-style="{
background: vm.colorSwitch ? myObject.personalColor : myObject.personRoleColor,
width: myObject.percentage + '%'
}" ...></span>

关于css - AngularJS 样式设置背景,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32954677/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com