I'm currently working on very lightweight Angular Elements with Ivy (v10.1.2).
When I don't import zone.js
in my polyfills.ts
and "disable" it in my main.ts
as follows:
platformBrowserDynamic()
.bootstrapModule(AppModule, { ngZone: 'noop' })
.catch(err => console.error(err));
then is it still relevant what kind of ChangeDetectionStrategy I set on my component?
So, if I trigger it manually by marking the component as dirty (ɵmarkDirty as markDirty
) and having the default ChangeDetectionStrategy, would the Noop-ChangeDetector traverse the whole tree? And if I would set it to changeDetection: ChangeDetectionStrategy.OnPush
would it just check the component at hand?
I actually asked the same question in a great medium article and got the following response (short version):
That actually answered my question, as I thought that we don't have a Change Detector, because we would be Change Detector (because we mark the Component dirty ourselves).
It goes on:
So my takeaway and in conclusion:
When disabling zone.js (we still have a ChangeDetector) and by using the default strategy (instead of the OnPush) and triggering the change detection manually (with markDirty), the ChangeDetector will check the whole tree (assuming every component has default change detection strategy). But when using OnPush, the ChangeDetector will only check the component at hand.