Edition 24/21: Angular 18

Edition 24/21: Angular 18

Angular 18 is out. For the first time, the main feature is an experimental one: the zoneless mode.

Until Angular 17, zone.js triggered Change Detection, which updates the DOM. Starting from Angular 18, we have a second trigger: the function markForCheck(), which runs automatically within the async pipe or when a Signal's value changes. That Signal must be used inside a template.

There are also other occurrences for markForCheck() like immutable property binding or handled DOM events.

markForCheck() triggering the Change Detection is not experimental but stable. It is a breaking change because the Change Detection might now also be triggered outside of zone.js.

Although that is a rare use case, we can also re-introduce the behavior as before via provideZoneChangeDetection({ignoreChangesOutsideZone: true}).

What is experimental, though, is that you can disable zone.js at all and only rely on markForCheck().

That is done via provideExperimentalZonelessChangeDetection().


Other features include the "Event Replay", which is important for server-side rendering. When the application hasn't hydrated, i.e. Angular hasn't been loaded yet, and users start clicking around, those events will be replayed after hydration.

provideClientHydration(withEventReplay())        

The redirectTo property in the Router configuration accepts, next to the existing string, now also a function. That means, when logic is required for the redirection, one doesn't have to fallback to router guards.

export const routes: Routes = [
  {path: '', component: HomeComponent},
  {
    path: '**',
    redirectTo: () => isNight() ? '/404-night' : '404-day'
  }
];        

<ng-content> accepts a default value. It is actually very straightforward ??:

<ng-content>Nothing to see here :) </ng-content>        

FormGroup, FormArray, and FormControl expose an events property, which provides all important events as an Observable:

export class AppComponent {
  name = new FormControl("", {validators: [Validators.required]})
  constructor() {
    this.name.events.subscribe((event: ControlEvent) => {
      if (event instanceof StatusChangeEvent) {
        console.log('status changed');
      }
      else if (event instanceof ValueChangeEvent) {
        console.log('value changed');
      }
      // ...
    })
  }
}        

A lot of features, like @defer, @if, @for are now stable (`effect()` is still in developer preview).

According to Alex Rickabaugh, tech lead of the framework, we can expect new features in the next versions as well.

For more information, check out the various videos, blog posts from the community, and the official channels.

Angular 18 Release - Developer Event

Official Blog Post


Stefano Marchisio

?? Sviluppatore web | Programmatore web | Freelance ? Front-end: Angular/TypeScript ? Back-end: ASP.NET MVC CORE C# ? Fullstack Software Engineer

9 个月

Interesting article. One question, when you talk about the new function "markForCheck()" and the option provideZoneChangeDetection( {ignoreChangesOutsideZone: true} )", are you referring to what is also called "Hybrid Mode / Hybrid Change detection in v18"? https://riegler.fr/blog/2024-04-17-zoneless-with-zoneless-hybrid

要查看或添加评论,请登录

Rainer Hahnekamp的更多文章

  • Ng-News 25/11: TypeScript's Port to Go, Q&A on SSR

    Ng-News 25/11: TypeScript's Port to Go, Q&A on SSR

    TypeScript is moving to Go for major speed boosts, while Angular’s Q&A confirmed Streaming is planned but not…

    2 条评论
  • Ng-News 25/10: Advanced Content Projection, Outlook 2025+

    Ng-News 25/10: Advanced Content Projection, Outlook 2025+

    Minko Gechev highlighted how the Ivy engine accelerated Angular’s development and outlined plans for selectorless…

  • Ng-News 25/09: Angular 19.2, httpResource

    Ng-News 25/09: Angular 19.2, httpResource

    Angular 19.2 is here, and the standout feature is the experimental httpResource.

  • Ng-News 25/08: DOM Sync Process, standardized Observable &?more

    Ng-News 25/08: DOM Sync Process, standardized Observable &?more

    Matthieu Riegler explains Angular’s new DOM synchronization process, replacing modern change detection. Meanwhile, the…

  • Ng-News 25/07: Q&A February, Micro Frontends

    Ng-News 25/07: Q&A February, Micro Frontends

    In February’s Q&A, the Angular team clarified how it only updates changed DOM parts, recommended folder-by-feature…

  • Ng-News 25/06: Angular Documentary

    Ng-News 25/06: Angular Documentary

    The Angular documentary by Honeypod explores its four key phases—from AngularJS to the Ivy rewrite and today’s Signals…

    1 条评论
  • Episode 25/05: Q&A Angular Strategy, Outlook Angular 19.2 & more

    Episode 25/05: Q&A Angular Strategy, Outlook Angular 19.2 & more

    Angular's 2025 strategy focuses on improving the developer experience in general, compatibility with the JavaScript…

  • Ng-News 25/04: Angular 19.1, Strategies for 2025, Q&A and?More

    Ng-News 25/04: Angular 19.1, Strategies for 2025, Q&A and?More

    Angular 19.1 has been released with new features like HMR for templates and a schematic for removing unused imports.

  • My favorite Angular Setup in 2025

    My favorite Angular Setup in 2025

    Angular continues to evolve rapidly. What should we use in 2025? Especially if we start with a new project.

    25 条评论
  • Angular in 2024: Key Milestones & Highlights

    Angular in 2024: Key Milestones & Highlights

    2024 has been an interesting year for Angular. To me, four things stand out: Long-term effects of the cooperation with…

    3 条评论

社区洞察

其他会员也浏览了