Validation 是否可以将ElementRef强制转换为NgControl?

Validation 是否可以将ElementRef强制转换为NgControl?,validation,angular,Validation,Angular,我正在尝试将自定义验证器创建为@指令,问题是在构造函数中我只能访问ElementRef对象,但是我需要NgControl中的一些方法 @Directive({ selector: "[my-directive][ngModel]", providers: [some providers here] }) export class MyValidator extends RootValidator { constructor(el: ElementRef, public rende

我正在尝试将自定义验证器创建为
@指令
,问题是在构造函数中我只能访问
ElementRef对象
,但是我需要
NgControl
中的一些方法

@Directive({
  selector: "[my-directive][ngModel]",
  providers: [some providers here]
})
export class MyValidator extends RootValidator {


  constructor(el: ElementRef, public renderer: Renderer) {
    super(el, renderer);
    // TODO: Here i need access to ngControl instead of ElementRef
    errorsFromServerEmitter.subscribe(next => {
        // ... some useful code here and then
        ngControl.updateValueAndValidity();
    })
  }

  validate(c: FormControl) {
    // ... some validations
    return errors;
  }
我需要以某种方式对服务器的响应作出反应。在这个回答中,我得到了“
扩展的
”错误,这些错误知道DB一致性和其他一些东西