有沒有其他人必須先支持Angular回到IE7?創建下拉列表時,我在8和7中都遇到了問題。Angular在下拉菜單中不顯示選項的正確文本
<select data-ng-model="relatedProduct.quantity" data-ng-init="setSelect(relatedProduct)">
<option data-ng-repeat="i in getNumber(relatedProduct.maxQuantity) track by $index" value="{{ $index }}">{{ $index }}</option>
</select>
忽略對select
的ng-model
和ng-init
。 getNumber()
是一個函數,它將從1返回給定的最大值,並因此返回將被渲染的最大選項數量。
我的問題是,當我打開下拉菜單時,每個選項的文本是{{ $index }}
。選項的值屬性是正確的,因爲每當我選擇一個新選項時,都會顯示正確的值。只有當下拉打開時,問題纔會發生。
任何幫助表示感謝,謝謝!
您是否嘗試過使用ngOptions? – 2014-10-02 15:55:36
「當我打開下拉菜單時,每個選項的文本都是{{$ index}}。」 - 你還期望它是什麼? – Blazemonger 2014-10-02 17:00:28
@Blazemonger我本來希望文本是代表數組中位置的數字。 1,2,3等。這適用於'value'屬性,但不適用於實際的元素文本。 – ashrobbins 2014-10-03 07:25:06