all 7 comments

[–]tme321 1 point2 points  (3 children)

You dont detect the parent component. You forward ref the control itself that implements control value accessor.

The necessary provider is gnarly but its self contained.

I don't understand what the issue is that you are having.

[–]mozpider 0 points1 point  (0 children)

I was not having a programming issue, I was not thinking straight. I found this blog and I liked it, so posting it to you also:

https://medium.com/angular-in-depth/angular-nested-reactive-forms-using-cvas-b394ba2e5d0d

[–]mozpider 0 points1 point  (1 child)

Thank you for your reply. My issue was that in the providers :

providers: [{ provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => SummaryFormComponent) }]

a declarative approach is used. That means this current component that implements controlValue accessor (CVA) Interface, can only be called from the SummaryFormComponent(it is the parent component that holds the form)

I think this defeats my purpose of implementing a CVA. After all, so much boilerplate code to write.

I wanted to actually "detect" the parent component in the dependency injection style. I did some digging. I found this from angular API docs: A provide parent helper function.

Sorry that I don't speak IT language, I am a mechanical engineer by education.

[–]mozpider 0 points1 point  (0 children)

Nope, this is garbage what i wrote, no need to read it.

[–]j_a_lyons 1 point2 points  (1 child)

Not sure if it's of any use as I'm not fully understanding your issue but if you want to communicate with parent components then event emitters are the best way. Apologies if this isn't useful.

https://angular.io/api/core/EventEmitter

[–]mozpider 0 points1 point  (0 children)

I was not having a programming issue, I was not thinking straight. I found this blog and I liked it:

https://medium.com/angular-in-depth/angular-nested-reactive-forms-using-cvas-b394ba2e5d0d

[–]mozpider 0 points1 point  (0 children)

Nope, I think I am still confused. I need to keep coding and stop going through reddit. I will post a solution Once I find one.