我正在尝试编写一个用于选择国家/地区的下拉列表,是否可以在国家/地区名称旁边添加国家/地区国旗?
<div class="chosen-input-group col-sm-10 ">
<select id="country_type" chosen data-placeholder="-- 國家 --" disable-search="false"
ng-options="country_.country_id as country_.name for country_ in vm.country_data"
ng-model="vm.item.country_id">
<option value=""> -- 國家 --</option>
</select>
</div>
最佳答案
您可以在选项标签上使用 ng-repeat,然后根据需要使用图像设置选项的样式
<select >
<option ng-repeat="country_ in vm.country_data"
value="country_.country_id"
style="background-image:url({{country_.name}}.png);">
{{ country_.name }}
</option>
</select>
关于html - Angular ng-选项添加图标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46440319/