ion-select not showing selected option with FormBuilder (Ionic 3)(离子选择不显示 FormBuilder 的选定选项(Ionic 3))
问题描述
取下面的html
<form [formGroup]="detailsForm">
<ion-list>
<ion-item>
<ion-label>Gaming</ion-label>
<ion-select formControlName="gaming">
<ion-option value="nes">NES</ion-option>
<ion-option value="n64">Nintendo64</ion-option>
<ion-option value="ps">PlayStation</ion-option>
<ion-option value="genesis">Sega Genesis</ion-option>
<ion-option value="saturn">Sega Saturn</ion-option>
<ion-option value="snes">SNES</ion-option>
</ion-select>
</ion-item>
</ion-list>
</form>
在你的组件中
this.detailsForm = this.formBuilder.group({
gaming:['nes',Validators.required]
});
我希望在加载视图时看到NES"作为选定选项.但是,它没有出现.如果您改为使用 [(ngModel)] ,它将起作用.
I would expect to see 'NES' as the selected option when the view is loaded. However, it does not appear. If you instead use [(ngModel)] it will work.
是我做错了什么,还是最近的 ionic 更新导致了这个问题?
Am I doing something wrong, or has the most recent ionic update caused this issue?
任何帮助都会很棒.
推荐答案
这只是3.1的问题.它要么是传递整个事件与过去的值相比的重大变化,要么与在用户交互之前组件加载时触发 ionChange (或第一件事导致第二件事)有关).暂时使用 3.0.
It's just an issue with 3.1. It's either a breaking change with passing the whole event vs. the value as it used to, or has something to do with firing ionChange when the component loads before user interaction (or the first thing is causing the second). Use 3.0 for now.
这篇关于离子选择不显示 FormBuilder 的选定选项(Ionic 3)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:离子选择不显示 FormBuilder 的选定选项(Ionic 3)
基础教程推荐
- 如何使用sencha Touch2在单页中显示列表和其他标签 2022-01-01
- 如何在特定日期之前获取消息? 2022-01-01
- Node.js 有没有好的索引/搜索引擎? 2022-01-01
- 每次设置弹出窗口的焦点 2022-01-01
- 什么是不使用 jQuery 的经验技术原因? 2022-01-01
- 为什么我在 Vue.js 中得到 ERR_CONNECTION_TIMED_OUT? 2022-01-01
- Javascript 在多个元素上单击事件侦听器并获取目标 2022-01-01
- 如何使用 CSS 显示和隐藏 div? 2022-01-01
- jQuery File Upload - 如何识别所有文件何时上传 2022-01-01
- WatchKit 支持 html 吗?有没有像 UIWebview 这样的控制器? 2022-01-01
