Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I need to display a "Loading" panel in an html template until the results have been retrieved and bound to a component vm view model variable. So something like this:

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

Additionally, I'll need to ensure that vm exists before attempting to reference vm.SearchResults. What would be a good way to do this in ng2+?

like image 756
user8570495 Avatar asked Sep 20 '25 15:09

user8570495


1 Answers

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

The exclamation (or bang) symbol is a "not" operator.

The question mark is the "safe navigation" operator.

Or you can use an or (||)

<div *ngIf="!vm || !vm.SearchResults">
like image 199
DeborahK Avatar answered Sep 22 '25 08:09

DeborahK