I want to create an accordion component. There should be only one tab opened at the time. Everything works fine, until I change the
ChangeDetectionStrategy.OnPush. I’m calling the
detectChanges method, but somehow it doesn’t trigger
My design of the accordion looks like this:
AccordionTabComponentis the child, it knows whether the tab is opened, or closed. Through
forwardRefhe can call parents
AccordionComponentis the parent component. Through
@ContentChildrenit knows about child tabs and it manages the closing/opening behavior.
- when user opens a tab by clicking, the child calls
closeOthersparent method with id of currently opened one. When parent component closes all opened tabs, calls the
detectChanges. It should trigger the change-detection and update the
DOM. But this last thing doesn’t happen.
I’m not sure what causing this, maybe it’s because of