I have a scenario where I am accessing two different NgForm one within Parent form #parentform and other in the Child component #childForm, and i want to check the validity of the controls of child form wether valid or not in parent component form. How to do this in angular4.
I also followed this link: Check if a form is valid from a parent component using Angular 4
everytime i am getting undefined for the reference of child component form.
My code is something like this.
parent.component.html
<form class="form-wrapper" (ngSubmit)="parentForm.form.valid && save()" #parentForm="ngForm" novalidate>
<input id="firstName" type="text" placeholder="" class="validate" name="firstName" [(ngModel)]="firstname_" #firstName="ngModel" required>
</form>
<child-component></child-component>
child.component.html
<form class="form-wrapper" (ngSubmit)="childForm.form.valid && save()" #childForm="ngForm" novalidate>
<input id="phoneNumber" type="text" placeholder="" class="validate" name="phoneNumber" [(ngModel)]="phone_" #phoneNumber="ngModel" required>
</form>
Now i want to validate the child component form "childForm" valid or not in parent form