解決angularjs 在ie8上面 ng-repeat的select控件兼容性問題

源代碼:

<select ng-model="dataset.db_id">
    <option ng-repeat="x in dataspaceinfo" value="{{x.db_id}}" >{{x.db_ch_name}}</option>
</select>

問題描述:

  在ie8下生成select的option時候使用ng-repeat,會造成下拉列表的列表顯示值爲{{x.displayname}}的形式,但是選中之後,選中值卻又是正確的,此問題不在chrome、firefox等最新版上出現。

解決:

  使用ng-option代替ng-repeat的實現。

  如果你說select綁定了value值,你該怎麼辦? x.value as x.displayName for x in dataspaceinfo

<select ng-model="dataset.db_id" ng-options="x.db_id as x.db_ch_name for x in dataspaceinfo"></select>

  解釋:x.value 作爲模型的ng-model的選中的值,x.displayName 爲下拉列表顯示的值,x爲data的其中一個元素。data是列表的對象集合。

原文:http://www.cnblogs.com/fenqi/p/6403996.html



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章