Subscribing in template using async pipe
See original GitHub issueI define the Observable as
this.cart$ = this.storage.observe('cart');
and then in the template I just subscribe {{(cart$ | async | json)}}
but I get null.
Note: If I try to fetch the value using a decorator @LocalStorage('cart') cart: Cart;
I see that the property cart does contain what I expect…
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Managing Subscriptions in Angular With the Async Pipe
Easily subscribe, unwrap data and unsubscribe from observables in Angular 2+ with the use of the async pipe in your templates.
Read more >subscribe() vs | async Pipe | by Tomas Trajan | Angular In ...
Using the subscribe() method and storing the state on the component instance, todos$. · The | async pipe unwraps the state object directly...
Read more >Angular: Use Observable Subscriptions & Async-Pipe to ...
Async -Pipe is an Angular built in tool to manage Observable-Subscriptions. We can easily simplify functionality of an Angular code using the async...
Read more >When to use the subscribe method or async pipe in Angular?
This post explains when to use subscribe method or async pipe in working with observable data in an Angular application.
Read more >Angular Reactive Templates with ngIf and the Async Pipe
As we can see, we have subscribed to the observable returned by the service layer and defined a local variable that contains the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hello @mackelito , Yes this project’s still alive since we’re using it in production in my company’ projects. What you are facing of is the expected behavior. The
observe()
method act as cold observable. If you don’t wanna use the decorators to bind your property you have to use thestartWith
operator to setup the start value.Glad to hear it’s still alive 👍
I had totally forgotten about the concept of hot/cold observables… 😄 thx for the reminder!