Yash Narang
Yash Narang

Reputation: 31

Access parent form validation in child component Angular 5 control value accessor

I referred this link : http://tylerscode.com/2017/03/splitting-angular-forms-controlvalueaccessor/#respond

I want to validate all fields in child component with control value accessor and template driven forms.

(This is link of issues on Stackblitz: https://stackblitz.com/edit/angular-qzioet)

Upvotes: 2

Views: 3525

Answers (1)

Chellappan வ
Chellappan வ

Reputation: 27293

ControlContainer

A base class for directives that contain multiple registered instances of NgControl. Only used by the forms module

Use viewProviders inside your child form

 viewProviders: [ { provide: ControlContainer, useExisting: NgForm }]

Example:https://stackblitz.com/edit/angular-cncupd

Upvotes: 2

Related Questions