因此,我正在尝试摆脱组件html中的红色弯曲。问题在于TypeScript / VS Code无法在unverifiedEmail
对象上看到属性errors
,因为它不是AbstractControl固有的。我使用的是自定义验证器,即属性的生成方式。该代码在这里:
custom.validators.ts
import { AuthService } from './../auth/auth.service'
import { AbstractControl } from '@angular/forms'
import { Injectable } from '@angular/core'
@Injectable()
export class CustomValidators {
constructor (private authService: AuthService) { }
unverifiedEmail (control: AbstractControl): { [key: string]: boolean } | null {
if (this.authService.unverifiedEmails.some(email => email === control.value)) {
return { unverifiedEmail: true }
}
return null
}
}
我的问题是:我如何“扩展” Abstract控件以包括此unverifiedEmail
属性的可能性,以便我的IDE不会理我。在自定义验证器和此模板之外,我没有与AbstractControl接口或errors
属性进行交互,因此,我似乎没有明显的机会导入扩展版本的AbstractControl(按通常的方式扩展界面)。
谢谢。