Who needs Inheritance and composition
summary
Argues for composition over inheritance and shows three concrete directives that replace component flags and duplicated logic: a renewal badge using Renderer2 to add classes and text, a structural settings directive using TemplateRef and ViewContainerRef, and a permission-by-selection directive with getter/setter inputs. Uses HostBinding/HostListener, async service calls (promises) and ngrx as an alternative, tests with mocked services and waitForAsync where specs pass, code generated with ng generate and published in separate repo branches.
AI-written summary · about
chapters (9)
- 0:00Start
- 5:34Duplicating Code
- 7:50Why We Will Favor of Composition over Inheritance
- 17:36How To Change Styles on a Directive
- 19:44Host Binding
- 20:15Testing the Directive
- 23:50Creating a Directive
- 27:47Template Ref
- 42:34Has Inheritance Impact on the Final Bundle Size
related talks
21mInheritance vs Composition
24mThe Architecture of Components
34mComposing Classes with TypeScript
10mWriting Compound Components in Angular
30mReactive parenting with Angular 2
20mEngineering Scalable Angular Components
31mAngular IVY with Composition API: the next level of reusability
24mComponents: Life Beyond Init and Destroy
