Angular template: use “as”-generated alias in the same instruction?

99封情书 提交于 2021-02-11 13:50:47

问题


I have an instruction like this:

<ng-container *ngIf="(someService.modules$ | async | filterByPurchased:true) as purchasedModules">
  some generated content
  <div *ngFor="let module of purchasedModules">{{module.name}}</div>
</ng-container>

But I also need to check if purchasedModules.length > 0. Unfortunately, purchasedModules is not a recognized variable in the instruction where the alias is created (so I can't just add && purchasedModules.length there), why? How to do it without another <ng-container> with another *ngIf?

来源:https://stackoverflow.com/questions/59421884/angular-template-use-as-generated-alias-in-the-same-instruction

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!