Select - options and AngularJS - add glyphicon to options

痞子三分冷 提交于 2020-01-05 08:12:24

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!