2016-08-23 115 views
0

我试图在ng-options中插入HTML标签,所以当文档呈现的选项在文本前有图标时。在ng选项中插入HTML标签

HTML:

<select chosen id="receive-country-selection" ng-model="current.RecipientCountry" ng-change="selectRecipientCountry(current.RecipientCountry)" ng-options="x.Name.toLowerCase() for x in data.RecipientCountries" > 
    <option value=""></option> 
</select> 

需要渲染成类似:

<select chosen id="receive-country-selection" ng-model="current.RecipientCountry" ng-change="selectRecipientCountry(current.RecipientCountry)" ng-options="x.Name.toLowerCase() for x in data.RecipientCountries" > 
    <option> 
     <span class="flag-sprite-container"> 
      <svg class="flag-sprite"> 
       <use xlink:href="someUrl"></use> 
      </svg> 
     </span> 
     some text 
    </option> 
</select> 

我想知道,如果有一个非jQuery的选项来做到这一点。

附加信息:我正在使用jQuery Chosen将select复制到uloptionli

回答

0

选项标签只支持文本。你也许可以使用div部分来查找其他实现,其行为就像下拉菜单一样。我知道twitter有一个叫做typeahead的库,它有这种行为。还有许多其他这样的库。

+0

jQuery Chosen实际上将选项标签转换为下划线列表项目,所以这部分是为什么我使用它 –