DEV Community

Discussion on: Understanding Angular's Control Value Accessor Interface

Collapse
nickpea profile image
NickPea

Thank Jennifer

I think its also good to clarify that the writeValue() CVA interface method isn't discharged after your onChanges() method is called. Meaning that the parent formControl (rating) doesnt update the child component property (value) when the formControl value is updated. It seemingly can only be done in the parent via calling the parent's formControl.setValue()/patchValue().

I think this is right, but please correct me because I'm making assumptions based on my own practice and I also noticed that right at the end of you child components model, the setRating() method does this manually rather than just call onChange() by itself.

No one explains this and I had to find out from looking at your code.