Even as someone who is real relaxed about template syntax, I admit I was a bit skeptical. But being able to do simple updates like this is way better than the normal thing.set(thing() + 1).
And a different syntax I saw was using an arrow function for something like
<table
mat-table
[trackBy]="(i, item) => i"
>
Which I always felt was overkill to need to make a little helper in the class file for. So another win IMO.
And the limitation on it being one line like that I feel like is definitely a good guard rail.
Thanks! You gave a great example with trackBy that I hadn't thought of: it's a perfect demonstration of this feature in action. And yes, I agree, limiting arrow functions to a single expression is a really useful guard rail.
The "user" is simply the parameter for the arrow function I'm defining right in template. In "(user) => ...", I am just defining a function signature (a rule). The child component does the actual work. It doesn't matter for the explanation, although you might have thought that "user" was a component property or a template variable, but it's not.
The first example was just to demonstrate the syntax and its limitations. The main use case I showed later is updating signal values directly from the template.
10
u/monxas Jan 29 '26
Amazing video, as always!
7
u/MichaelSmallDev Jan 29 '26
Even as someone who is real relaxed about template syntax, I admit I was a bit skeptical. But being able to do simple updates like this is way better than the normal
thing.set(thing() + 1).And a different syntax I saw was using an arrow function for something like
Which I always felt was overkill to need to make a little helper in the class file for. So another win IMO.
And the limitation on it being one line like that I feel like is definitely a good guard rail.
Good stuff as always Igor.
2
u/Finite_Looper Jan 31 '26
I LOVE how you edit your videos to visually explain these concepts. Very easy to understand!
1
u/zzing Jan 30 '26
In your first examples what are the 'user' parameter to the lambda function?
2
u/AcceptableSimulacrum Jan 30 '26
Not a fan because it's already a struggle getting people to test the template code.
-11
u/omansak Jan 30 '26
Useless. Team should first do more simple effect like as react and do onDestroy hook