如何将 *ngIf 绑定到模板中的 *not* 条件?

how to bind *ngIf to *not* condition in template?

我需要在 html 模板中显示一个 "Loading" 面板,直到检索到结果并将其绑定到组件 vm 视图模型变量。所以像这样:

<div *ngNotIf="vm.SearchResults">
Please Wait
</div>

此外,在尝试引用 vm.SearchResults 之前,我需要确保 vm 存在。在 ng2+ 中执行此操作的好方法是什么?

<div *ngIf="!vm?.SearchResults">

感叹号(或感叹号)是一个 "not" 运算符。

问号是"safe navigation"运算符。

或者您可以使用或 (||)

<div *ngIf="!vm || !vm.SearchResults">