繁体   English   中英

使用条件内的可观察值评估 *ngIf

[英]Evaluating *ngIf with observable value inside condition

我很难理解为什么在下面提到的方式中使用*ngIf会抛出Template Parse Error: Parser Error: Missing expected ) at ...

<ng-container *ngIf="true && (temp$ | async as temp)">
  {{temp}}
</ng-container>

重构上述代码的工作原理

<ng-container *ngIf="true">
  <ng-container *ngIf="temp$ | async as temp">
    {{temp}}
  <ng-container>
</ng-container>

我可以在不使用嵌套容器的情况下做到这一点吗?

您可能正在寻找的是以下内容(您只需要移动右括号):

<ng-container *ngIf="true && (temp$ | async) as temp">
  {{temp}}
</ng-container>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM