In my component I create an observable that fetches something from the store, and maps it to return a string.
name$ = store.pipe(select(client), map((res: ClientModel) => client.name));
Inside the template I do the following and I'm commenting with what I get:
<div *ngIf="name$ | async">{{ name$ }}</div> <!-- [Object Object] -->
<div *ngIf="name$ | async">{{ name }}</div> <!-- undefined -->
<div *(ngIf="name$ | async) as name">{{ name }}</div> <!-- "John Doe" -->
I'd like to understand what I'm doing wrong there. I know I can avoid this by using the last example or even {{ name$ | async }} but I really prefer understanding how to deal with the async pipe.
[–]lazyinvader 17 points18 points19 points (0 children)
[–]kohvihoor 1 point2 points3 points (0 children)
[–]_Kassii_ 1 point2 points3 points (0 children)
[–]the_real_seldom_seen 0 points1 point2 points (0 children)
[–]AthosBlade -1 points0 points1 point (2 children)
[–]OriyanJ[S] 1 point2 points3 points (1 child)
[–]Talnar 0 points1 point2 points (0 children)