In all Angular versions < 17 it was possible to declare new variable names, or better: create variable aliases in the templates, like this simplfied example:
<ng-container *ngIf="objectlist$ | async as list">
{{ list.name }}
</ng-container>
Now Angular 17 has introduced the new @if syntax (what I really like). So I would convert the snippet like this:
@if (objectlist$ | async as list) {
{{ list.name }}
}
However this is not working because as list doesn't work with the new syntax scheme. But how can I achieve the logic from my initial script same with the new syntax?
Alias is still supported on
@ifin the control flow syntax if you add a semi colon (;) after theasyncpipe:However, alias is not supported on
@ifwith@elsein the control flow syntax.@ifis supported just for backwards compatibility. See this Issue on the Angular GitHub repository: Allow to alias the @else if blocks in control flow syntax #52103.The relevant parts are:
and