0

I have a condition that I am unable to determine if "not":

*ngIf="searchResults['@odata.count'] !== null && searchResults['@odata.count'] >= 0"

Note, this does not work:

*ngIf="searchResults['@odata.count'] == null && searchResults['@odata.count']< 0"

that I want to write an ngIf "not". Similar to:

*ngIf="!(searchResults['@odata.count'] !== null && searchResults['@odata.count'] >= 0)"

Is there a way to do this solely working with the condition given?

georgeawg
  • 48,608
  • 13
  • 72
  • 95
simple
  • 2,327
  • 7
  • 35
  • 55

1 Answers1

1

There are a few things that you could use:

  1. use *ngIf *condition*; else tempalteRef How to use *ngIf else?

  2. separate logic in getter(or method): in .ts file

get showSearch() {
  return searchResults['@odata.count'] !== null && searchResults['@odata.count'] >= 0;
}

in template use *ngIf=showSearch and *ngIf=!showSearch

andriishupta
  • 497
  • 4
  • 8
  • also, if searchResults['@odata.count'] == null, how it could be less than zero together with null ? searchResults['@odata.count']< 0 – andriishupta Jul 28 '20 at 18:51