简体   繁体   中英

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 )

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM