Answer: Performance optimization can be achieved through:
Lazy Loading: Load modules only when needed.
Change Detection Strategy: Use OnPush to reduce checks.
TrackBy in ngFor: Helps Angular track changes in lists.
Using AOT Compilation: Ahead-of-Time compilation reduces the load time.
<div *ngFor="let item of items; trackBy: trackById">{{ item.name }}</div>
trackById(index: number, item: Item): number {
return item.id; // unique id
}
No comments:
Post a Comment