The async Pipe
Subscribe in templates without manual cleanup.
What the async pipe does
The async pipe subscribes to an Observable (or Promise) in the template, renders the latest emitted value, and automatically unsubscribes when the component is destroyed.
Basic usage
Bind an observable directly in the template and pipe it through async.
@Component({
template: '<p>{{ message$ | async }}</p>'
})
export class HelloComponent {
message$ = of('Hello from RxJS');
}