Imagine you have an Angular app that feels slow when you click buttons or load pages. Why does performance tuning matter in this case?
Think about what users feel when an app is slow.
Performance tuning improves how fast the app reacts, making users enjoy using it without frustration.
Consider an Angular component that updates many times per second. What is the likely effect on performance?
Think about what happens when a task repeats too often.
Too many change detection cycles cause slowdowns because Angular spends time checking all bindings repeatedly.
Choose the code that properly sets OnPush change detection strategy in an Angular component.
Look for correct enum usage and capitalization.
ChangeDetectionStrategy.OnPush is the correct enum value with exact capitalization.
Given this Angular code snippet, why might the app freeze when updating a large list?
<div *ngFor="let item of items">{{item.name}}</div>Assume items is a large array updated frequently.
Think about how Angular tracks list items in *ngFor.
Without a trackBy function, Angular re-renders the whole list on each change, causing freezes with large arrays.
Consider an Angular component that subscribes to an observable in ngOnInit but forgets to unsubscribe in ngOnDestroy. What is the likely outcome?
Think about what happens if you keep listening to something after you no longer need it.
Not unsubscribing causes memory leaks because the subscription stays active, holding resources.