Select - 选项和 AngularJS - 将字形添加到选项

Select - options and AngularJS - add glyphicon to options

我使用这个 select - 我的 AngularJS 应用程序中的选项:

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

现在我将为每个选项值添加一个字形:

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

有这样的可能吗?

我不知道 ng-options 的方法,但你可以使用 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>