Angular 12 References/ Core
🍀 Angular References


A callback method that performs custom clean-up, invoked immediately after a directive, pipe, or service instance is destroyed.

ngOnDestroy(): void
Links & Tutorials


The following snippet shows how a component can implement this interface to define its own custom clean-up method.

@Component({selector: 'my-cmp', template: `...`})
class MyComponent implements OnDestroy {
  ngOnDestroy() {
    // ...