Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular 当选择选项选择为0值时,使表单无效_Angular - Fatal编程技术网

Angular 当选择选项选择为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

当slect选项更改为0时,我想使我的表单无效。
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([])
    });