Angular 自定义验证器不显示角度误差

Angular 自定义验证器不显示角度误差,angular,angular-validation,Angular,Angular Validation,这是我的自定义验证器: form = new FormGroup({ temperatureMid: new FormControl(0, [ this.secondLimitGreaterFirst(), Validators.required ]) }); secondLimitGreaterFirst(): ValidatorFn { return (): {[key: string]: boolean} => { i

这是我的自定义验证器:

form = new FormGroup({
    temperatureMid: new FormControl(0, [
      this.secondLimitGreaterFirst(),
      Validators.required
    ])
  });

secondLimitGreaterFirst(): ValidatorFn {
    return (): {[key: string]: boolean} => {
      if (1 === 1) { // only for testing
        return { greater: true };
      } else {
        return { greater: false };
      }
      };
    }
现在我想为这个自定义验证器向用户显示一个错误,但我不知道如何显示

<mat-form-field>
                  <input matInput type="number" placeholder="{{ 'device.configure.temperaturePlaceholderMid' | translate }}" [(ngModel)]="data.tempMid" formControlName="temperatureMid"> 
                  <mat-error *ngIf="form.get('temperatureMid').hasError('secondLimitGreaterFirst')">Zweiter Wert muss größer sein</mat-error>
                  <mat-error *ngIf="form.get('temperatureMid').hasError('required')">{{ 'input.errors.required' | translate }}</mat-error> 
                </mat-form-field>

茨威特·韦特·穆斯·格雷尔·塞因
{{'input.errors.required'| translate}}

应该是
form.get('temperatureMid')。hasError('greater')
此外,如果没有错误返回
null
,则不是对象。有关@Bojankogj有用注释的更多上下文,请参阅Angular文档。感谢所有:)