选择-选项和AngularJS-将glyphicon添加到选项 [英] Select - options and AngularJS - add glyphicon to options

查看:31
本文介绍了选择-选项和AngularJS-将glyphicon添加到选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在AngularJS应用程序中使用以下select-选项:

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>

有可能这样做吗?

推荐答案

我不知道使用ng-options的方法,尽管可以使用ng-repeat:

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>

这篇关于选择-选项和AngularJS-将glyphicon添加到选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆