Angular - Lifecycle Hooks
Consider this Angular component code snippet:
What will happen when this component is removed from the view?
export class TimerComponent implements OnDestroy {
intervalId = setInterval(() => console.log('tick'), 1000);
ngOnDestroy() {
clearInterval(this.intervalId);
console.log('Timer stopped');
}
}What will happen when this component is removed from the view?
