ngOnDestroy()

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

ngOnDestroy(): void

Example

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() {
    // ...
  }
}