2016-08-23 133 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實際上將選項標籤轉換爲下劃線列表項目,所以這部分是爲什麼我使用它 –

相關問題