I have a parent component and in the template, I have a ngFor which generates child components. In this parent template, I have a submit button that should be disabled until all generated child components' validations are true. I mean, in the child component I have 3 fields that I should validate and after all children components are valid the submit button in the parent component should be enabled.
parent.component.html
<div *ngFor="let condition of conditions">
<child-component></child-component>
</div>
.
.
.
<button>Submit</button>
child.component.html
<form [formGroup]="frmGrp">
<input type="text" formControlName="name" />
<input type="text" formControlName="address" />
<input type="text" formControlName="phone" />
</form>
child.component.ts
export class ChildComponent {
frmGrp: FormGroup;
constructor(private fb: FormBuilder){
this.frmGrp = this.fb.group({
name: ["", Validators.required],
address: ["", Validators.required],
phone: ["", Validators.required]
});
}
}
What is the best practice to achieve this goal?