【问题标题】:AngularJS select, set the background color of 1 item of the dropdownAngularJS选择,设置下拉菜单1项的背景颜色
【发布时间】: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 version

【问题讨论】:

标签: javascript css angularjs select


【解决方案1】:

因此,这不会是您想要的答案,但是您将无法以跨浏览器的方式完成此操作而无需伪造它。对于另一个项目,我想完成与此类似的事情,唯一的方法是制作一个虚假的选择对象或使用像

这样的第 3 方库

https://select2.github.io/examples.htmlhttps://github.com/angular-ui/ui-select

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-06-03
    • 2019-03-19
    • 1970-01-01
    • 2016-11-23
    相关资源
    最近更新 更多