Загрузка...

New in Angular 21.2: Arrow Functions in Templates

Angular 21.2 introduces support for arrow functions in component templates, a major update that allows developers to write more concise reactive UI code. With this feature, templates can now include arrow functions with implicit returns, enabling updates to signal values directly from the template.

This eliminates the need for intermediate component methods for simple view logic and improves readability and maintainability for UI interactions.

The main intended use of arrow functions in templates is view logic only, not business logic. This allows templates to react to user interactions and update signals directly, keeping state updates simple, predictable, and efficient.

I explain this feature in detail in the video, including the new practices for working with arrow functions and signals in templates.

✔️ Optimization
Arrow functions in templates are evaluated efficiently by the Angular compiler: each function is created once and reused across change detection cycles.

Timestamps
0:00 Intro
0:14 Implicit return limitations
0:44 Pipe usage limitations
1:08 Update signals directly in templates

ℹ️ Note: Some examples in this video use arrow functions in templates for demonstration purposes only. While this syntax illustrates the capabilities and limitations of Angular templates, using arrow functions in templates in real projects should be evaluated carefully.

Thanks to the @Angular Team for a new useful feature.

ℹ️ Source: https://github.com/angular/angular/pull/66294

Follow me on:
▪️LinkedIn: https://www.linkedin.com/in/igorsedov/
▪️Twitter: https://twitter.com/TheIgorSedov
▪️Bluesky: https://bsky.app/profile/igorsedov.com
▪️Instagram: https://www.instagram.com/theigorsedov/

Website: https://igorsedov.com
Email: me@igorsedov.com

Angular is a registered trademark of Google and/or its affiliates. Other names may be trademarks of their respective owners/holders. Use of them does not imply any affiliation with or endorsement by them.

#angular #angular21 #angularforbeginners

Видео New in Angular 21.2: Arrow Functions in Templates канала Igor Sedov
Яндекс.Метрика
Все заметки Новая заметка Страницу в заметки
Страницу в закладки Мои закладки
На информационно-развлекательном портале SALDA.WS применяются cookie-файлы. Нажимая кнопку Принять, вы подтверждаете свое согласие на их использование.
О CookiesНапомнить позжеПринять