Angular5自定义验证器:ng:Identified';密码g';没有定义。

Angular5自定义验证器:ng:Identified';密码g';没有定义。,angular,angular5,frontend,Angular,Angular5,Frontend,在angular5中工作,尝试实现密码和确认密码的自定义验证器 这是.html: 在同一个文件.ts中,在这个类中我有一个函数: 问题出在.html文件中,我收到以下错误: ng: Identified 'passwordG' is not definded. The component declaration ,Template variable declaration and element reference do not contain such a member , 第行: <

在angular5中工作,尝试实现密码和确认密码的自定义验证器

这是.html:

在同一个文件.ts中,在这个类中我有一个函数:

问题出在.html文件中,我收到以下错误:

ng: Identified 'passwordG' is not definded. The component declaration ,Template variable declaration and element reference do not contain such a member  ,
第行:

<div *ngIf="(passwordG.invalid && passwordG.touched)" class="col-sm-3 text-danger">


有什么想法吗

passwordG
本身未在组件中定义

如果要访问表单中的控件,可以使用


form.controls['passwordG']
form.get('passwordG')
passwordG
本身未在组件中定义

如果要访问表单中的控件,可以使用


form.controls['passwordG']
form.get('passwordG')

使用
form.controls['passwordG']
代替。感谢您的帮助:),如果您可以将其添加为答案,以便我可以为您标记:)没问题@dEs12ZER:)完成!改为使用
form.controls['passwordG']
。感谢您的帮助:),如果您可以将其添加为答案,我可以为您标记:)没问题@dEs12ZER:)完成!
 function passwordMatch(control: AbstractControl):{[key: string]: boolean}{

  const password = control.get('password');
  const Confirmationpassword = control.get('Confirmationpassword');

  if( !password || !Confirmationpassword) {
    return null; }

  if(password.value === Confirmationpassword.value){
    return null;
  }

  return {
    mismatch:true
  }

}
ng: Identified 'passwordG' is not definded. The component declaration ,Template variable declaration and element reference do not contain such a member  ,
<div *ngIf="(passwordG.invalid && passwordG.touched)" class="col-sm-3 text-danger">