Angular FAQ: Top Questions
39. What is the role of async pipe in Angular templates?
The async
pipe in Angular automatically subscribes to an Observable or Promise and returns the latest value. It also handles unsubscribing to prevent memory leaks.
<p>{{ user$ | async }}</p>
- Eliminates need for manual subscriptions.
- Used in combination with observables from services or reactive forms.