quma
quma

Reputation: 5733

Select - options and AngularJS - add glyphicon to options

I use this select - options in my AngularJS application:

<select data-ng-model="userFilter" data-ng-options="c as c.firstname + ' ' + c.surname for c in vm.users">
    <option></option>
</select>

and now I will add a glyphicon to each option value:

<span class="glyphicon glyphicon-user"></span>

is there a possibility to do it like this?

Upvotes: 1

Views: 714

Answers (1)

dev8080
dev8080

Reputation: 4020

I don't know a way with ng-options, though you could use ng-repeat:

<select data-ng-model="userFilterIndex" data-ng-change ="userFilter = vm.users[ userFilterIndex ]">

    <option data-ng-repeat="c in vm.users" value="{{ $index }}">
        <span class="glyphicon glyphicon-user"></span>
        {{ c.firstname + ' ' + c.surname }}
    </option>

</select>

Upvotes: 1

Related Questions