将选择值与Angular 4中的ngModel关联 [英] Associate select value to ngModel in Angular 4
本文介绍了将选择值与Angular 4中的ngModel关联的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用Angular4轮胎将ngValue与ngModel关联,但得到 Null
.因此,请帮助我将 ngValue
连接到 ngModel
I'm using Angular4 tyring to associate ngValue to ngModel but getting Null
. So kindly help me to connect ngValue
to ngModel
<select name="gender" [(ngModel)]="nameForm.gender">
<option [ngValue]="Male">Male</option>
<option [ngValue]="Female">Female</option>
<option [ngValue]="Others">Others</option>
</select>
推荐答案
环绕单引号'Male'
<select name="gender" [(ngModel)]="nameForm.gender">
<option [ngValue]="'Male'">Male</option>
<option [ngValue]="'Female'">Female</option>
<option [ngValue]="'Others'">Others</option>
</select>
这篇关于将选择值与Angular 4中的ngModel关联的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文