0

I have a ui select dropdown in angular that contains various text values. Using CSS I added font awesome icons to the left of each value. I want to add a specific font awesome icon to the left of the 'All' choice in the dropdown, however I'm unable to target the specific dropdown choice. Not sure if this can be accomplished using only CSS or if I need to use JS to target it somehow. In any even any help would be greatly appreciated thank you.

screenshot

                <div class="form-group">
                    <ui-select id="teamMemberType" ng-model="historyCtrl.queryParams.teamMemberType" theme="bootstrap" ng-change="historyCtrl.filterContent()">
                        <ui-select-match placeholder="Search">{{$select.selected.display}}</ui-select-match>
                        <ui-select-choices group-by="'group'" repeat="option.value as option in (historyCtrl.filters.options.teamMemberType | filter: $select.search) track by option.value">
                            <span id="created" ng-bind-html="option.display| highlight: $select.search"></span>
                        </ui-select-choices>
                    </ui-select>
                </div>
1
  • is your ALL choice an option tag in your select? Commented May 8, 2017 at 18:41

2 Answers 2

1

Without seeing the resulting HTML / CSS I don't know exactly how to apply this to your code, but there are multiple ways of targeting a single element with CSS using pseudo selectors. The one I expect you need is:

:first-child The first element among a group of sibling elements.

This will only select elements which are the first child of it's parent. Simply apply your CSS using this.

In other cases, if the position of your desired element is unknown, you could use ng-class to apply a class if the option equals a particular value. Then target the element with that class.

Sign up to request clarification or add additional context in comments.

Comments

1

You can apply a specific style to the first item using this code:

 <ui-select-match placeholder="Search" ng-style="{{$index==0}} && {'background-color':'green'}">{{$select.selected.display}}</ui-select-match>

ng-class won't work for you as far as i know ui-select has a bug applying a class on the ui-select-match. So applying an inline style of the icon should work, by checking if the item index is =0

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.