Html 爱奥尼亚精选韩元';是否使用动态值正确渲染?离子4
我在使用ionic 4和ionic select时遇到了一个问题。 当我有一些数据并且正在绑定数据时,问题就出现了。 在本例中,我已经有一个预选数据,当我这样做时,离子选择不能正确渲染Html 爱奥尼亚精选韩元';是否使用动态值正确渲染?离子4,html,angular,ionic-framework,ionic4,Html,Angular,Ionic Framework,Ionic4,我在使用ionic 4和ionic select时遇到了一个问题。 当我有一些数据并且正在绑定数据时,问题就出现了。 在本例中,我已经有一个预选数据,当我这样做时,离子选择不能正确渲染 <ion-item class="transparent"> <ion-label position='floating'>{{ 'GENDER_TXT' | translate}}</ion-label> <ion-selec
<ion-item class="transparent">
<ion-label position='floating'>{{ 'GENDER_TXT' | translate}}</ion-label>
<ion-select interface="popover" color='medium' [(ngModel)]='Gender' formControlName='genderTxt'>
<ion-select-option *ngFor='let g of Genders' [value]='g'>{{g.GENDER}}</ion-select-option>
</ion-select>
</ion-item>
删除ngmodel指令
[(ngmodel)]='Gender'
使用被动表单时,可以通过更新表单控件genderText
值来设置所选值
this.getGendersSub=this.proxy.Get_Genders(param).subscribe((数据)=>{
性别=数据;
this.form.get(`genderText`).setValue(this.Genders[0]);
});
demo删除ngmodel指令
[(ngmodel)]='Gender'
当您使用反应式表单时,您可以通过更新表单控件genderText
值来设置所选值
this.getGendersSub=this.proxy.Get_Genders(param).subscribe((数据)=>{
性别=数据;
this.form.get(`genderText`).setValue(this.Genders[0]);
});
演示如果您使用的是formControl,则需要将Value方法修补到选定的value@MhmdKorhani我已经用working demo@malbarmawi更新了我的答案,谢谢你更新了我的答案,这是一个ionic 3演示,对我来说很好,问题是ionic 4和ionic angular模块,使用以下方法修复了我的问题:在收到我的动态数据之前隐藏select元素。如果使用formControl,则需要将Value方法修补到selectedvalue@MhmdKorhani我已经用working demo@malbarmawi更新了我的答案,谢谢你更新了我的答案,这是一个ionic 3的演示,对我来说效果很好,问题在于ionic 4和ionic angular模块,我的问题是使用以下方法解决的:在收到动态数据之前隐藏select元素。
this.getGendersSub = this.proxy.Get_Genders(param).subscribe((data) => {
this.Genders = data;
this.Gender = this.Genders[0];
});