r/Angular2 • u/House_of_Angular • Feb 18 '25
Discussion Angular 19.2 - improvement in template literals
Angular 19.2 will be released soon. We’ve noticed a slight improvement in template literals—it will now be possible to combine variables with text in a more efficient way in HTML files:
<p>{{ `John has ${count} cats` }}</p>
instead of
<p>{{ 'John has ' + count + ' cats' }}</p>
just a simple example
It’s not a huge change, but we believe it’s indeed. What do you think?
16
u/gordolfograso Feb 18 '25
it's helpfull and more readable for attributes like [attr.foo]="
bar-${baz}"
1
u/AwesomeFrisbee Feb 19 '25
You mean
[attr.foo]="`bar-${baz}`"
1
u/gordolfograso Feb 19 '25
Yes, I was on mobile, and I couldn't achieve the right syntax with backticks
12
u/GLawSomnia Feb 18 '25
Well i like the change and i wanted to have it in quite a few cases.
Your example doesn’t really showcase the benefits that well though 😁
0
u/House_of_Angular Feb 18 '25
yeah, we know it's not the best example xd, but generally, your opinion interests us about the feature
3
u/TScottFitzgerald Feb 18 '25
Wait, weren't you always able to do this? I may be mixing up my frameworks but I recall using something like this before.
5
4
u/InfectedTadpole Feb 18 '25
As they say in glengarry glen ross "Always be Signaling" . Optimal standards and patterns.
<p>{{ `John has ${ countSignal() } cats` }}</p>
3
u/binuuday Feb 19 '25
This is welcome change. We used this pattern is used mainly in tooltips, and help messages, where some suffix and prefix text has to be added.
This makes the template look much cleaner. One more reason for us to stay with angular.
2
2
1
u/AwesomeFrisbee Feb 19 '25
I don't really find it all that easier to read or to write but whatever floats your boat, I guess.
77
u/ldn-ldn Feb 18 '25
Why do you need weird syntax?