html ngif-异步-AS-else.html

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了html ngif-异步-AS-else.html相关的知识,希望对你有一定的参考价值。

<div *ngIf="user$ | async as user; else userNotFound"> 
  <p>{{ user.name }}</p> 
  <p>{{ user.age }}</p> 
  <img [src]="user.icon"> 
</div> 
<ng-template #userNotFound> 
  <p>not found</p> 
</ng-template>

以上是关于html ngif-异步-AS-else.html的主要内容,如果未能解决你的问题,请参考以下文章

如何使用异步管道值处理`ngIf`?

嵌套在 ngIf 中时,异步管道订阅无法正常工作

将两个异步订阅放在一个 Angular *ngIf 语句中

如何在Angular 6中将异步管道的结果分配给没有*ngIf的变量

angular入门篇(2)——*ngIf,数据绑定事件,属性绑定

Ionic 4 Angular模板与异步管道绑定到可观察