问题
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?
回答1:
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>
来源:https://stackoverflow.com/questions/43109309/select-options-and-angularjs-add-glyphicon-to-options