taiga-family / ng-polymorpheus

Polymorpheus is a tiny library for polymorphic templates in Angular.

Home Page:https://stackblitz.com/edit/polymorpheus-demo

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[FEATURE] Angular 13.2 Mayby something usefull for this library?

kbrilla opened this issue · comments

Hi,
going through the changelog for Angular 13.2.rc I found this change:
feat(core): allow for the injector to be specified when creating an embed…
angular/angular#14935
angular/angular@b49ffcd

I'm pretty sure this library could utilize this feature.

To be exact PolymorpheusTemplate should be not needed anymore as we could pass Injector to the template as we do with Component so it would get a correct instance of ChangeDetectorRef

Yes, we could add POLYMORPHEUS_CONTEXT so that it is accessible on templates as well, but we cannot solve change detection issue with this, because you cannot substitute ChangeDetectorRef — custom injector acts like a "Module injector", meaning it's for fallback, not for replacing — DI first looks in the «natural» injector. At least that's what I've been told by the Angular team. I need to test that 🙂 So while adding custom injector can be helpful, I don't think it warrants a version bump on its own.

This feature got rolled back and postponed to v14, looks like it was exactly because the behavior I describe in a post above was confusing.

Doesn't seem like there's any benefit going higher than Angular 12 at this point so I'm closing this issue.