linkOnDestroy
npm Package | @angular/core |
---|---|
Module | import { OnDestroy } from '@angular/core'; |
Source | core/src/metadata/lifecycle_hooks.ts |
Lifecycle hook that is called when a directive, pipe or service is destroyed.
linkInterface Overview
interface OnDestroy {
ngOnDestroy(): void
}
linkHow To Use
@Component({selector: 'my-cmp', template: `...`})
class MyComponent implements OnDestroy {
ngOnDestroy() {
// ...
}
}
linkDescription
ngOnDestroy
callback is typically used for any custom cleanup that needs to occur when the
instance is destroyed.