Angular - Lifecycle Hooks
Given this Angular component code, what will happen when the component is destroyed?
export class SampleComponent implements OnDestroy {
private timerId: any;
constructor() {
this.timerId = setInterval(() => console.log('tick'), 1000);
}
ngOnDestroy(): void {
clearInterval(this.timerId);
console.log('Timer cleared');
}
}