Reputation: 4782
I'm relatively new to reactive programming and I'm trying to create an Angular service which can display notifications to the user. So far this is what I have:
https://stackblitz.com/edit/angular-rxjs-notifications?file=app%2Fapp.component.html
But I noticed that when you click the "Queue Notification" button my *ngIf="message$ | async"
<div>
appears correctly but the inner {{ message$ | async }}
text doesn't appear unless you click the button twice in a row without clicking "Clear"
Thanks in advance!
Upvotes: 1
Views: 210
Reputation: 16837
Your first problem can be solved like this.
<div *ngIf="message$ | async as messages" >
<div>{{ messages }}</div>
</div>
We store the result from the pipe in a local variable called messages
. This way you avoid a situation in which the inner async
pipe is not called after the outer one emits.
Upvotes: 1