• Overview
@angular/router

withExperimentalAutoCleanupInjectors

function

Enables automatic destruction of unused route injectors.

API

function withExperimentalAutoCleanupInjectors(): ExperimentalAutoCleanupInjectorsFeature;

Description

When enabled, the router will automatically destroy EnvironmentInjectors associated with Routes that are no longer active or stored by the RouteReuseStrategy.

This feature is opt-in and requires RouteReuseStrategy.shouldDestroyInjector to return true for the routes that should be destroyed. If the RouteReuseStrategy uses stored handles, it should also implement retrieveStoredRouteHandles to ensure injectors for handles that will be reattached are not destroyed.

Jump to details