我想为图像中给出的 ui-select
的每个选项添加不同的 CSS,以便每个选项以不同的 text-color
这是带有代码的 Plunk:Plunk
我也试过给出不同的 li
如下所示
<ui-select-choices repeat="item in (itemArray) track by item.id">
<li style="color:green;">Pending</li>
<li style="color:red;">Rejected</li>
<li style="color:blue;">Approved</li>
</ui-select-choices>
但是当我选择该元素时,css
将不会保留。
最佳答案
您可以为数组中的每个元素关联颜色。像这样:
$scope.itemArray = [
{id: 1, name: 'Pending', color: 'green'},
{id: 2, name: 'Rejected', color: 'red'},
{id: 3, name: 'Approved', color: 'blue'},
];
然后,在 ui-select
中,
<ui-select-match>
<span style="color: {{$select.selected.color}}" ng-bind="$select.selected.name | limitTo: 20"></span>
</ui-select-match>
<ui-select-choices repeat="item in (itemArray) track by item.id">
<span style="color: {{item.color}}" ng-bind="item.name"></span>
</ui-select-choices>
关于html - 为 ui-select 的每个选项添加不同的 CSS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44282878/