UISelect多,应用CSS到所选择的项目之一 [英] UISelect multiple , apply CSS to one of the selected items
问题描述
我试着去找到办法,自定义CSS仅适用于在UISelect多重选择的项目之一。
Im trying to find ways to apply custom CSS to only one of the selected items in UISelect Multiple.
<ui-select id="productSelect" class="form-control" multiple ng-model="contractsHeader.ProductList" ng-click="addProductOpen()" on-select="onProductSelected($item)" on-remove="onProductRemoved($item)" ng-disabled="!selectedAdvertisers.selectedAdvertiser || !selectedAdvertisers.selectedAdvertiser.AdvertiserKey || selectedAdvertisers.selectedAdvertiser.AdvertiserKey== ' '" ng-required="true" autofocus>
<ui-select-match>{{getProductDisplayText($item)}}</ui-select-match>
<ui-select-choices ui-disable-choice="product.Product_Code == null" refresh="searchByTypes('Products',$select.search)" refresh-delay="0" repeat="product in products track by $index | filter:$select.search">
<div style="cursor:pointer;" ng-if="product.Product_Code == null && securitySettings.addOtherProducts" ng-click="addProductOpen($select, $event)"><{{product.Product_Description}}></div>
<div ng-if="product.Product_Code != null">{{product.Product_Description}} ({{product.Product_Code}})</div>
</ui-select-choices>
</ui-select>
下面是UISelect-匹配
here is an excerpt of UISelect-Match
<ui-select-match>{{getProductDisplayText($item)}}</ui-select-match>
我试过条件纳克级应用CSS只有一个元素,但CSS类从未申请过关于该项目。
I tried conditional ng-class to apply CSS to only one element but CSS class is never applied on that item.
推荐答案
这是目前的UI选择请一个已知问题:的 https://github.com/angular-ui/ui-select/issues/277
This is currently a known issue for ui-select please see: https://github.com/angular-ui/ui-select/issues/277
从本质上讲,是因为UI的选择具有纳克级的属性,你都无法有效地应用自定义动态类。
Essentially, because ui-select has ng-class properties you are unable to effectively apply your custom dynamic classes.
更新03/08:我解决我的问题(虽然不是pretty)与吴式,设置连接到一个范围的变量在控制器的CSS值(取决于你的条件)(作为OBJ点亮),或者根本就很难code它NG式中的HTML文件=。
Update 03/08: I resolved my issue (While not pretty) with ng-style, set the css value in your controller(dependent on your condition) attached to a scope variable (as an obj lit), or simply hard code it in the html file within ng-style="" .
这篇关于UISelect多,应用CSS到所选择的项目之一的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!