-
Notifications
You must be signed in to change notification settings - Fork 27k
Closed
Labels
area: commonIssues related to APIs in the @angular/common packageIssues related to APIs in the @angular/common packagefeatureIssue that requests a new featureIssue that requests a new featurefreq3: high
Description
Goals
When writing Rx style code it is often necessary to write code like this
{{ (userObs|async).?lastName}}, {{ (userObs|async).?firstName}}
The issue is that:
- every
asynccreates a listener and - the need to use the
.?makes coding cumbersome.
What is needed is to be able to subscribe to the observable once and then refer to it in subsequent location. Additionally we need a way to display an alternative template while the observable has not yet yielded a value.
Proposal
- Allow
ngIfto assign data to local value. - Add an
elsefeature tongIfso that an alternative template can be shown until the observable yields a value.
<div *ngIf="userObs | async; else loading; let user">
{{ user.lastName}}, {{ user.firstName }}
</div>
<template #loading>
loading...
</template>
NOTE: the microsyntax is consistent with existing implementation of the microsyntax. For expanded form see:
<template [ngIf]="userObs | async" [ngIfElse]="loading" let-user>
{{ user.lastName}}, {{ user.firstName }}
</template>
<template #loading>
loading...
</template>
DzmitryShylovich, fxck, AdamJo, olegdunkan, jamesbirtles and 19 more
Metadata
Metadata
Assignees
Labels
area: commonIssues related to APIs in the @angular/common packageIssues related to APIs in the @angular/common packagefeatureIssue that requests a new featureIssue that requests a new featurefreq3: high