angular - 使用带有“||”的异步管道 操作员无法正常工作
问题描述
我想使用带有“||”的异步管道 运营商,但我不知道如何。例如:
<div class="col-md-12" *ngIf="(someSubscription$ | async) as users || someCondition">
解决方案
您可以使用括号来组合异步管道的输出和条件。
*ngIf="(someSubscription$ | async) || someCondition as output"
假设这someSubscription$
不是Observable<boolean>
,那么您可以执行严格的测试来区分output
。
<div *ngIf="(someSubscription$ | async) || someCondition as output">
<div *ngIf="output === true else other">
output from someSubscription$ must be falsy
</div>
<ng-template #other>
{{output.name}}
</ng-template>
</div>
推荐阅读
- html - ContentDocument 在 vba 中不起作用
- python-3.x - 将作业从 laravel 分派到 AWS SQS 并使用 python 在 lambda 中创建队列工作者
- django-models - 如何使模型不区分大小写
- php - 将我的 Joomla 网站从 Apache 迁移到 NginX 时无法通过引用错误传递参数 1
- git - 如何仅在 git fork 中集成特定文件?
- kotlin - 暂停`withTimeout`
- java - 如果从 Tomcat 调用,Firefox headless 永远不会从截图中返回
- python - 如何打印 Tensorflow V2 keras 模型的所有激活形状(比 summary() 更详细)?
- function - 寻找关于隐式函数类型与显式函数类型的解释
- javascript - 手机关机时在 Chrome/Firefox 手机上重复音频