Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Property 'controls' does not exist on type 'AbstractControl'. #305

Open
jayakumarim opened this issue Jul 7, 2021 · 0 comments
Open

Property 'controls' does not exist on type 'AbstractControl'. #305

jayakumarim opened this issue Jul 7, 2021 · 0 comments

Comments

@jayakumarim
Copy link

Hi,
I created a reactive from with nested FormBuilder, While validate the form i got error like *Property 'controls' does not exist on type 'AbstractControl'. at line editPersonalInfoForm.controls.child.controls.id.hasError('required')".

This is my typescript code
` editPersonalInfoForm: FormGroup;

constructor(private formBuilder: FormBuilder) { this.editPersonalInfoForm = this.formBuilder.group({ id: ['', [Validators.required]], name: ['', [Validators.minLength(5), Validators.required]], child: this.formBuilder.group({ id: [ '', [Validators.required]], name: [''] }) });
} `

This my html
<form [formGroup]="editPersonalInfoForm" > <input type="text" name="id" formControlName="id"> <input type="text" name="name" formControlName="name"> <small class="error-text" *ngIf="editPersonalInfoForm.controls.name.hasError('maxlength')"> Address Line 1 can't exceed 100 characters. <br> </small> <div formGroupName="child"> <input type="text" name="id" formControlName="id"> <small class="error-text"

       `  *ngIf="editPersonalInfoForm.controls.child.controls.id.hasError('required')">
    Address Line 1 can't exceed 100 characters. <br>
  </small>
  <input type="text" name="name" formControlName="name">
</div>
<button class="btn btn-primary">send</button>
`

Please some one help me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant