-1

I have a component where I want to hide an element if the user is null. Currently it shows if the user exists:

 <ng-container *ngIf="user | async as _user">

Here is the component.ts part:

 this.user = this.auth.userSubject.asObservable();

I want to do the opposite of:

 <ng-container *ngIf="user | async as _user">

so that it only shows if the user$ is null

at the top of the logout component is:

 userSubject: BehaviorSubject<UserModel>;

when they log out:

this.userSubject.next(null);
John
  • 47
  • 1
  • 8

2 Answers2

1

If you want the opposite behavior just negate your *ngIf

<ng-container *ngIf="!(user | async)">

Quick example: StackBlitz

Marek W
  • 699
  • 4
  • 14
0

<ng-container *ngIf="!user | async"> should probably work for you