选择不支持Ionic Framework的默认选项 [英] Select default option not working with Ionic Framework

查看:121
本文介绍了选择不支持Ionic Framework的默认选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Ionic Framework。

我想输入第一个选项作为默认值,但这样做不起作用。

我该怎么办? / p>

 < select ng-model =newSpesaAereo.valuta> 
< option ng-selected =selected> Euro< / option>
< option> Dollaro< / option>
< option> Dollaro canadese< / option>
< option> Sterlina< / option>
< / select>


如果我使用Google Chrome开发者实用工具分析页面,请观看此文。





如果我编辑这个HTML并删除所选的行,然后Euro显示。



为什么会发生这种情况?

解决方案

您需要使用 ng-selected 而不是仅仅选中。

https://docs.angularjs.org/api/ng/directive/ngSelected

 < select ng-model =newSpesaAereo.metodoPagamento> 
< option ng-selected =selected> Carta di credito< / option>
< option> Bancomat< / option>
< option> Contanti< / option>
< option> Altro< / option>
< / select>


I am using Ionic Framework.
I would like to enter the first option as the default, but doing it this way does not work.
What can I do?

<select ng-model="newSpesaAereo.valuta">
    <option ng-selected="selected">Euro</option>
    <option>Dollaro</option>
    <option>Dollaro canadese</option>
    <option>Sterlina</option>
</select>

If I analyze the page with Google Chrome Developer Utility I watch this.

If I edit this HTML and I delete the selected row, then Euro is visible.

Why is this happening?

解决方案

You need to use ng-selected instead of just selected.

https://docs.angularjs.org/api/ng/directive/ngSelected

<select ng-model="newSpesaAereo.metodoPagamento">
  <option ng-selected="selected">Carta di credito</option>
  <option>Bancomat</option>
  <option>Contanti</option>
  <option>Altro</option>
</select>

这篇关于选择不支持Ionic Framework的默认选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆