Fired when the component or directive instance is destroyed.
import { Component, OnDestroy } from '@angular/core';
@Component({
selector: 'so-ondestroy-component',
templateUrl: 'ondestroy-component.html',
styleUrls: ['ondestroy-component.']
})
class OnDestroyComponent implements OnDestroy {
ngOnDestroy(): void {
console.log('Component was destroyed !');
}
}