Angular's New @for Block Features
Вставка
- Опубліковано 1 лип 2024
- The @for block, part of Angular's new control flow syntax, is great for repeating HTML elements in our templates. And it provides useful features such as an @empty block, odd and even row indication, and easier change tracking.
In this video, we walk through five fun features of the @for block.
Links
Code: stackblitz.com/~/edit/fun-for...
UA-cam video: "Angular's New Template Syntax: Control Flow": • Angular's New Template...
UA-cam video: "Automatically Migrate to Angular's New Control Flow Template Syntax": • Automatically Migrate ...
Content
00:00 @for block
00:46 @empty block
01:25 $index
02:14 $first, $last, $odd, $even
04:03 $count
04:57 track
00:00 Wrap up
▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
😊About Me
Hey! I'm Deborah Kurata
I'm a software developer and UA-cam content creator. I speak at conferences such as VSLive and ng-conf. I write articles for freeCodeCamp. And I'm a Pluralsight author with courses in the top 10 most popular (out of 7,000+) for over 5 years. For my work in support of software developers, I've been recognized with the Microsoft Most Valuable Professional (MVP) award, and I'm a Google Developer Expert (GDE).
View my UA-cam content: / @deborah_kurata
Contact me on Twitter: / deborahkurata
Find my Pluralsight courses: www.pluralsight.com/profile/a...
Access my freeCodeCamp articles: www.freecodecamp.org/news/aut...
▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
#angular
#angulartutorials
#angulartutorial
#angulardevelopers
#angularbestpractices
#angular17newfeatures
#angular17newfeature
#angular17features
#@for
#@forinangular
#@forinangular17
#angularnewfeatures
#featuresinangular17
#angular@forloop
#angular@for
#angularlatestfeatures
#whatis@forinangular
#angularfeaturesandupdates
#angular17featuresandupdates
#angular@forcontrolflow
#angular@forsyntax
#angular17featureswithexample
#@forinangular17withexample
#angularbestpractices - Наука та технологія
@empty and @for track without declaring a new component method are great features
Yep! 😊
Fantastic, thank you so much Deborah!!
Thanks! 😊
great video, i saw your ng-conf video but they have disabled the comment section, so i take this section to greet you and thank you for such an excellent video
Thanks! 😊
As always, you come up with great stuff from the basics. Thanks.
Thank you!
Concise and helpful. Thanks Deborah!
Glad to hear that. Thank you!
Great as usually
Thank you!
❤❤❤❤❤❤❤❤ thank you
Thanks to you! 😊
Great content. Many thanks
Thank you! 😊
Your lessons are excellent as always. Very beautiful hairstyle for the intro, you are a beauty. Thank you for being you, Deborah!
Thank you so much! 😊
thanks!
You bet! Thank you!
nice. wasnt aware of odd, even, count.
Glad that it was useful! Thanks!
What if instead of creating the variables inside @for we use the $ variables ($first, $last, etc.) directly in the template? Are there any disadvantages?
Yes! The aliasing is optional. I've always done that out of habit, but the let is not required. You can use the variables directly in the template.
❤️
😊
if using track function should not we call it with this new @syntax? track trackSnak(snack)?
You can just pass the function name. That's easier/shorter.
But if you did want to call it manually, you'd have to pass both arguments: trackSnack($index, snackItem)
for some reason your stackblitz url is not working
Sorry about that. I just fixed it. Can you try again?
@@deborah_kurata thanks for sharing it is working now 👍
I am curious to know why people don't prefer to keep their business logic inside service file, instead they prefer to use a service as a rest API layer only ?
It is recommended that business logic go in a service. This sample application was focused on the @for block, so I didn't take the time to move all of the signals from the component to the service, if that's what you are referring to.
And definitely things like displaying the row number and odd/even highlighting would be UI and not really business logic, right?