![](/img/trans.png)
[英]Angular 2: Is there a way of handling Observable (async) in the Component instead of of using the pipe in the template?
[英]angular 6 template with async pipe
我在组件中具有以下模板代码:
<div *ngIf="current_user | async as cu">
<a href="#" *ngIf="!(cu.id > 0)">Sign In [{{cu | json}}]</a>
</div>
json管道输出:
{ user: { id: 1 }}
但异步管道似乎没有。 始终显示锚标记。 如果id> 0(用户已登录),则应将其隐藏。
它应该是:
<div *ngIf="current_user | async as cu">
<a href="#" *ngIf="!(cu.user.id > 0)">Sign In [{{cu | json}}]</a>
</div>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.