👨🏫 Co-Founder of This is Learning, Organizer of AarhusJS
✍️ Writer, Speaker, FOSS Maintainer 📗 Author
🏆 Microsoft MVP 🌟 GitHub Star
🌊 Nx Champion 🦸 Angular Hero of Education
One thing I've noticed when extending classes in Angular is that when we have constructor injected dependencies, we have to add a constructor to the top-most level class with the necessary dependencies to make Angular's dependency injection work.
Have you noticed this when using class-based mixins?
UI Consultant, Maker & Technical Writer.
I write about JS, TS, Rx, Angular & all things Front End
🇮🇹🇬🇧
Follow me on Twitter: https://twitter.com/gc_psk
Founder of https://makerkit.dev
If you use a Mixin, you don't really need to re-inject the dependency, but you do need to tell TS that the class to which the mixin is applied to does have that particular service/type.
Awesome article, Giancarlo. Amazing!
One thing I've noticed when extending classes in Angular is that when we have constructor injected dependencies, we have to add a constructor to the top-most level class with the necessary dependencies to make Angular's dependency injection work.
Have you noticed this when using class-based mixins?
Hi Lars, thanks a lot again!
If you use a Mixin, you don't really need to re-inject the dependency, but you do need to tell TS that the class to which the mixin is applied to does have that particular service/type.
For example, Angular Material uses interfaces such as "HasElementRef" (github.com/angular/components/blob...)