2
votes

I'm trying to use angular dynamic component loader and I'm facing a change detection issue when I'm using ChangeDetectionStrategy.OnPush. I read about it in this git issue and saw this Plunker and from what I understand is that dynamic added component are detach from their parent change detection tree and onPush won't work (Only default).

I was wondering if there's a way to still use ChangeDetectionStrategy.OnPush. Is there a way to assign component to certain tree? For now I changed all my regarding components from onPush to Default and the app works fine but I do prefer to use the onPush strategy.

1
from what I understand is that dynamic added component are detach from their parent change detection tree - that's not true, dynamically added components are checked in the same way as static components in the template when embedded views are checkedMax Koretskyi

1 Answers

2
votes

You can just invoke change detection from the parent using the ComponentRef reference you get when you create the component, every time you change the status of the component.
Within the dynamic component there shouldn't be a difference.