0

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)">&lt;{{product.Product_Description}}&gt;</div>
                <div ng-if="product.Product_Code != null">{{product.Product_Description}} ({{product.Product_Code}})</div>
            </ui-select-choices>
        </ui-select>

here is an excerpt of UISelect-Match

<ui-select-match>{{getProductDisplayText($item)}}</ui-select-match>

I tried conditional ng-class to apply CSS to only one element but CSS class is never applied on that item.

AlexMA
  • 9,842
  • 7
  • 42
  • 64
Sunil Vurity
  • 830
  • 9
  • 14

2 Answers2

1

This is currently a known issue for ui-select please see: https://github.com/angular-ui/ui-select/issues/277

Essentially, because ui-select has ng-class properties you are unable to effectively apply your custom dynamic classes.

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="" .

Kevin Alwell
  • 131
  • 10
0
<ui-select-match ng-class="(expression) ? 'class1' : 'class2'">
    {{getProductDisplayText($item)}}
</ui-select-match>
Samir Alajmovic
  • 3,247
  • 3
  • 26
  • 28
  • You could use :first-child on the template html, as I assume you compile the element in the directive? – Samir Alajmovic Mar 06 '15 at 14:41