Angular 当选择选项选择为0值时,使表单无效
当slect选项更改为0时,我想使我的表单无效。Angular 当选择选项选择为0值时,使表单无效,angular,Angular,当slect选项更改为0时,我想使我的表单无效。value=“0”应为value=“”,以使所需的验证生效。我正在使用angular 5反应式表单方法。value=“0”应为value=“感谢您在@Igoram使用反应式表单方法时给出的答案。组件文件中的任何修改 <select name="tenure" formControlName="tenure" class="form-control" (change)="TenureChan
value=“0”
应为value=“”
,以使所需的验证生效。我正在使用angular 5反应式表单方法。value=“0”
应为value=“
感谢您在@Igoram使用反应式表单方法时给出的答案。组件文件中的任何修改
<select name="tenure"
formControlName="tenure"
class="form-control"
(change)="TenureChange($event.target.value)">
<option value="0">--select--</option>
<option *ngFor="let tenur of ddltenure">{{tenur}}</option>
</select>
<span class="validation-block"
*ngIf="!planmodeForm.get('tenure').valid && planmodeForm.get('tenure').touched">
Please select tenure
</span>
this.planmodeForm = new FormGroup({
'planmode': new FormControl(null, [Validators.required, Validators.pattern(this.planmodePattern)]),
'tenure': new FormControl(null, Validators.required),
'maxstudents': new FormControl(null, Validators.required),
'maxusers': new FormControl(null, Validators.required),
'notificationconf': new FormArray([])
});