选择和输入无效

时间:2019-05-01 15:10:06

标签: forms validation angular6

所有字段填写完毕后,我需要解锁“提交”按钮,但是它不起作用... 我定义了所有必填字段,但是当我填写所有字段时,按钮保持锁定状态。 这是我的代码。 我找不到解决方案,有什么主意吗?谢谢你

  <form [formGroup]="patientExamForm" (ngSubmit)="onSubmitExam()">

    <div class="form-group">
      <label for="listExamPrenotation">Esame da prenotare: </label>
      <select required class="form-control" formControlName="examToBeDone" (change)='changeAlerts($event.target.value)' >
        <option  *ngFor="let exam of listExamPrenotation" [value]="exam.name" >
          {{exam.name}}
        </option>
      </select>
    </div>

    <div class="form-group">
      <label for="listAlerts">Seleziona medico: </label>
      <select required class="form-control" formControlName="alerts" (change)='changeTime($event.target.value)' >
        <option *ngFor="let examName of examAlerts"  [value]="examName" >
          {{examName}}
        </option>
      </select>
    </div>
    <div class="form-group">
      <label for="nota">Note aggiuntive: </label>
      <input class="form-control" type="text" formControlName="nota">
    </div>
    <div class="col-4">
      <form class="form-inline">
        <div class="form-group">
          <div class="input-group">
            <input required class="form-control" placeholder="yyyy-mm-dd"
                   name="d2" #c2="ngModel" [(ngModel)]="model" ngbDatepicker #d2="ngbDatepicker" (dateSelect) = "onSelect($event)" >
            <div class="input-group-append">
              <button class="btn btn-outline-secondary" (click)="d2.toggle()" type="button"><i class="fa fa-calendar"></i></button>
            </div>
          </div>
        </div>
      </form>
    </div>
    <div class="form-group">
      <label for="listTime">Seleziona orario: </label>
      <select required class="form-control" formControlName="time">
        <option *ngFor="let time of examTime"  [value]="time">
          {{time}}
        </option>
      </select>
    </div>


    <button type="submit" [disabled]="patientExamForm.invalid" class="btn btn-dark"><i class="fa fa-edit"></i> Aggiungi prenotazione</button>
  </form>
</div>

0 个答案:

没有答案