【发布时间】:2015-05-13 18:55:25
【问题描述】:
我有一个包含许多项目的下拉列表,如果我单击选择以显示列表,我想以不同的颜色突出显示该列表中的一些项目。
预期行为:当我们点击 Select(在选择任何项目之前)时,如果标签 Obligatory 为 true,如何让列表中的“Section3”项目以黄色(背景部分)突出显示?
$scope.globalSections = [
{name: 'Section1', department: 'Summary'},
{name: 'Section2', department: 'Group1'},
{name: 'Section3', department: 'Group1', obligatory: true},
{name: 'Section4', department: 'Group2'},
{name: 'Section5', department: 'Group2'}
];
$scope.selectedSection = $scope.globalSections[0]; // Summary
<select ng-model="selectedSection" ng-options="section.name group by section.department for section in globalSections">
【问题讨论】:
-
是的,代码看起来不错,但 Plnkr Proposed 在 Chrome 或 Safari 中似乎不起作用(显示颜色)。
标签: javascript css angularjs select