DEV Community

Cover image for Ng-News 25/50: Auto-Destroy for Router Providers, Signal Forms
ng-news for This is Angular

Posted on

Ng-News 25/50: Auto-Destroy for Router Providers, Signal Forms

Angular will bring auto-destroy for router providers and more updates around Signal Forms. The community shares new articles, talks, and practical examples.

Auto-Destroy for Router Providers

A new feature for the router will land in Angular 21.1. This might surprise some developers, because many assumed this behavior was already standard.

If a service is provided only at component level, so not in root, the service gets destroyed together with the component. This does not happen when a service is provided in the router. In that case, it stays alive across navigations. With Angular 21.1, it will become possible to destroy such services when users navigate away. The PR exists, but it has not been merged yet.

feat(router): add controls for route cleanup #65991

This commit introduces a new feature to automatically destroy EnvironmentInjectors associated with routes that are no longer active or stored. This helps in managing memory by releasing resources held by unused injectors.

Key changes:

  • Added shouldDestroyInjector and retrieveStoredRouteHandles to RouteReuseStrategy.
  • Introduced withExperimentalAutoCleanupInjectors provider function to opt-in to this feature.
  • Implemented a "mark and sweep" algorithm to identify and destroy unused injectors.
  • Added a dev mode warning if the strategy implements destruction methods but the feature is not enabled.
  • Added integration tests to verify the behavior.

This commit also destroyDetachedRouteHandle, a standalone function that allows developers to explicitly destroy the component associated with a DetachedRouteHandle.

We chose to implement this as a standalone function rather than adding a destroy() method to the DetachedRouteHandle type to avoid breaking changes. Currently, DetachedRouteHandle is defined as {}, and many applications mock it as such. Adding a required method to the interface would break these existing tests and usages.

By using a standalone function, we can safely cast the handle to its internal type and invoke destruction without altering the public contract of the handle itself.

This feature is particularly useful for RouteReuseStrategy implementations that need to drop stored handles and ensure the associated components are properly cleaned up to prevent memory leaks.

resolves #27290 resolves #37095 resolves #15873

Signal Forms Guide with compatForm

Mateusz Stefańczyk from House of Angular published another long article on Signal Forms, adding to the growing list of community content. The article is interesting because it also covers compatForm. This function can work with a Signal as well as with a FormControl or FormGroup. It therefore offers a migration path from existing forms to Signal Forms.

Alex Rickabaugh @ Jason Lengstorf

Alex Rickabaugh, tech lead of the Angular framework, was a guest on a livestream with Jason Lengstorf. The session had two parts. The first part focused on the underlying concepts and the motivation behind Signal Forms. The second part moved into live coding.

From Alex’s perspective, Signal Forms are clearly the direction forward. He also gave a good overview of the three different maturity states the Angular team uses for features.

...And so that's really what experimental is for us is...hey, this is not fully baked yet, but we're letting you on to it early because we really value that kind of on the ground feedback about how it's working for real use cases.

Then we have developer preview, which is more of, like a release extended release candidate. Like we think this is feature complete, this could ship as stable, but we want to give developers one more chance to kind of bang on it and see what breaks.

If we release an API as stable,... if we are going to make a breaking change to it, we give you two major versions to migrate, or from the time we deprecate something to the time we remove it. Or we have some kind of auto migration for you that will make sure that as you update the code, it kind of follows along.

Ng-Glühwein

ng-Glühwein, an Angular conference in Vienna, took place for the third year in a row, and the recordings are already available on YouTube. The talks covered a wide range of topics.

Push-based, as the organizer, contributed three talks. Julian Jandl and Christopher Holder spoke about performance. Adrian Romanski covered accessibility. Thomas Trajan presented modern strategies for dynamic component loading. Michael Hablich gave an AI-focused talk on the DevTools MCP server. Elise Patrikainen spoke about Angular resources.
Members of the Angular team were also present. Matthieu Riegler talked about Signals, and Alan Agius covered secure management of third-party libraries.

Push-Based - YouTube

Push-Based is a close knit group of IT experts offering their knowledge and services in #Angular #RxJS #NestJS #JavaScript #TypeScript #webperf and more.

favicon youtube.com

Ng-Belgrade 2026

Ng-Belgrade has announced its revival for next year. The event will take place on May 7th, and ticket sales are already open.

NG Belgrade Conf 2026

NG Belgrade Conf 2026 is the largest Angular conference in the Balkans. It takes place in Belgrade, Serbia, including a Conference Day on May 7th and a Workshop Day on May 8th. Join us to explore the latest trends and best practices in Angular!

favicon angularbelgrade.org

Top comments (0)