In Angular (13) is there a way to assign the result of a function to a variable (in the .html
part of a component, not template) having multiple conditions in ngIf
JavaScript
x
4
1
<div *ngIf="let getMyVar() as myVar && isVisible && isClean">
2
{{ 'this is myVar: ' + myVar }}
3
</div>
4
if not what workaround is possible to implement?
Advertisement
Answer
did not find anything better than splitting the ngIf
in two
JavaScript
1
6
1
<ng-container *ngIf="getMyVar(); let myVar">
2
<div *ngIf="isVisible && isClean">
3
{{ 'this is myVar: ' + myVar }}
4
</div>
5
</ng-container>
6