In the newest versions of Angular, the @HostBinding and @HostListener decorators are no longer intended for use. As the new documentation states, they “exist exclusively for backwards compatibility”. There’s a new, more streamlined way to do this type of thing, and if you’ve worked with Angular in the past, it may look familiar to you. It’s kind of an old concept made new again. In this video we’ll look at a couple of examples I created for past videos about these decorators, and we’ll replace them with the newer methods. Also, we’ll update a few other concepts in these components and directives along the way too.
------------------------------------------------------------------------------
👕 Be the coolest developer in the room with these Angular tees! (https://www.teepublic.com/user/dev-drip)
------------------------------------------------------------------------------
🔗 Demo Links:
@HostBinding Before (https://stackblitz.com/edit/stackblit...)
@HostBinding After (https://stackblitz.com/edit/stackblit...)
@HostListener Before (https://stackblitz.com/edit/stackblit...)
@HostListener After (https://stackblitz.com/edit/stackblit...)
------------------------------------------------------------------------------
📚 Additional Resources:
Angular Host Elements Documentation (https://angular.dev/guide/components/...)
------------------------------------------------------------------------------
📖 Chapters:
0:00 – Introduction
0:45 – Using Host Element Class Binding to Replace the @HostBinding Decorator
2:15 – How to Convert Form Value Observable to a Signal
3:08 – How to Use an effect() to Toggle a Class When a Form Field Status Changes
4:24 – Using Host Element Events to Replace the @HostListener Decorator
5:33 – How to Convert an Output Using the @Output Decorator to the New output() function
6:14 – Conclusion
------------------------------------------------------------------------------
#angular #angulartutorial #angulartraining
Watch video Host decorators are dead... use host element binding instead online without registration, duration hours minute second in high quality. This video was added by user Brian Treese 05 July 2024, don't forget to share it with your friends and acquaintances, it has been viewed on our site 1,32 once and liked it 8 people.