What is the difference between subscribe and the async pipe?

Angular HTTP, RxJS and state · Freshers

Model answer

With subscribe, you receive values in code and must store them and unsubscribe yourself when the component is destroyed (unless the stream completes). With the async pipe in the template, Angular subscribes, shows the latest value and unsubscribes automatically.

Prefer the async pipe or toSignal for data shown on screen. Use subscribe only for side effects, and then use takeUntilDestroyed to clean up.

Learn this topic

Angular Tutorial: Beginner to Advanced .

Sign in to add your own answer.

More questions