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)


- 使用RSelum从网站(报纸档案)中抓取多个网页 2022-09-06
- Flexslider 箭头未正确显示 2022-01-01
- Quasar 2+Apollo:错误:找不到ID为默认的Apollo客户端。如果您在组件设置之外,请使用ProvideApolloClient() 2022-01-01
- CSS媒体查询(最大高度)不起作用,但为什么? 2022-01-01
- 失败的 Canvas 360 jquery 插件 2022-01-01
- addEventListener 在 IE 11 中不起作用 2022-01-01
- Css:将嵌套元素定位在父元素边界之外一点 2022-09-07
- 如何使用 JSON 格式的 jQuery AJAX 从 .cfm 页面输出查 2022-01-01
- Fetch API 如何获取响应体? 2022-01-01
- 400或500级别的HTTP响应 2022-01-01