Host decorators are dead... use host element binding instead

Опубликовано: 05 Июль 2024
на канале: Brian Treese
1,322
86

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


Смотрите видео Host decorators are dead... use host element binding instead онлайн без регистрации, длительностью часов минут секунд в хорошем качестве. Это видео добавил пользователь Brian Treese 05 Июль 2024, не забудьте поделиться им ссылкой с друзьями и знакомыми, на нашем сайте его посмотрели 1,32 раз и оно понравилось 8 людям.