Template variables in Angular using the new @let syntax

preview_player
Показать описание
In Angular, we can now create variables for reuse right within our component templates. Now that might seem odd but it's actually pretty cool. If you're like me, you may have a hard time understanding the benefits at first so, in this video, I'll show you how to create these template variables, and then I'll show you several different possible use cases and benefits to help you better understand why you may want to use them in your projects.

------------------------------------------------------------------------------

------------------------------------------------------------------------------

🔗 Demo Links:

------------------------------------------------------------------------------
📚 Additional Resources:

------------------------------------------------------------------------------

📖 Chapters:
0:00 – Introduction
0:35 – The Anatomy of the @let Syntax
1:24 – A Simple String Variable Example
2:35 – Simplifying Async Pipe Subscriptions With @let
4:48 – Simplifying Repetitive Complex Logic with @let
6:04 – Creating a Dynamic Variable Based on Form Control Value with @let
7:16 – Signal Type Narrowing with @let
8:29 – Variables Using @let Syntax Can't be Reassigned
9:14 – Variables Using @let are Scoped
9:52 – Conclusion

------------------------------------------------------------------------------

#angular #angulartutorial #angulartraining
Рекомендации по теме
Комментарии
Автор

Really great examples. What I like most is the simplification of async logic with let. In the past I often had the problem of wrapping whole parts of the template inside an if-statement or even (worse) using multiple async pipes on the same observable. Just putting a let on top of the template is a game changer. Thanks for the idea!

crebuh
Автор

Awesome. I have been working with angular since angular 7 and it was always inexplicable to me why they don't add 'template let' as a part of framework because double subscriptions in template were always a problem)

НикитаКлусович
Автор

Very cool feature, but this open doors for people do tone's of s***... I can imagine how messy some code bases may end up.

PauloSantos-yutn