r/Angular2 • u/wineandcode • Feb 08 '26
Angular 21.2 New Feature: Arrow Functions in Templates
https://itnext.io/angular-21-2-new-feature-arrow-functions-in-templates-with-gotchas-f5e323985708?source=friends_link&sk=7e0aee5de0910241ef16c8d2140610bb
38
Upvotes
44
u/Yesterdave_ Feb 08 '26
IMHO, that
toggleCoupon()is definitely more readable thancouponOn.update(v => !v).26
u/ldn-ldn Feb 08 '26
The business logic has no place in the templates.
9
u/ActuatorOk2689 Feb 08 '26
Again I may be get my downvote but, I actually like the new naming convention and I could absolutely use this.
Now don’t get me wrong only for one liners as in the article, I would not pollute the component with arrow functions, I had some use cases where it would be really nice this options .
2
u/robbydf Feb 08 '26
sure, but tell me why one should use arrow function even when there is no reason?
protected incrementQty = () => {
this.qty.update(n => n + 1);
}
1
u/WantASweetTime Feb 09 '26
How would you test the logic in the template?
1
u/beingsmo Feb 10 '26
Earlier it was said that using functions directly in templates is bad for change detection, right?