Skip to content

About

Guard to destroy Angular lazy-loaded route modules

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

DestroyModule

Guard to destroy Angular lazy-loaded route modules

Angular Versions Compatibility

destroy-module Angular
14.x.x >= 14 < 15
13.x.x >= 13 < 14
12.x.x >= 12 < 13
11.x.x >= 11 < 12
10.x.x >= 10 < 11
9.x.x >= 9 < 10
8.x.x >= 8 < 9
7.x.x >= 7 < 8
6.x.x >= 6 < 7
5.x.x >= 5 < 6
4.x.x >= 4 < 5

Table of contents

What is DestroyModule

Angular modules keep alive until you call their destroy() methods manually. This causes that provided services in modules will keep alive too. For more information you can read angular issues angular/angular#24962, angular/angular#37095. DestroyModule is guard that call destroy() method of guarded lazy-loaded route modules on deactivation.

Getting started

npm install @norefx/ngx-destroy-module
# If you use yarn
yarn add @norefx/ngx-destroy-module
import { DestroyModuleGuard } from '@norefx/ngx-destroy-module';

@NgModule({
  imports: [
    RouterModule.forRoot([
      {
        path: `example-path`,
        canDeactivate: [DestroyModuleGuard],
        loadChildren: () => import(`./example.module`).then((m) => m.ExampleModule),
      },
    ]),
  ],
  providers: [DestroyModuleGuard],
})
export class ExampleModule {}

Demo

Stackblitz Demo

DestroyModule.demo.webm

About

Guard to destroy Angular lazy-loaded route modules

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages