DuB loxx
DuB loxx

Reputation: 235

How to hide a div if an observable is empty

The Project is on Angular 8.

This question may be very basic, I didnt dive deep into observables yet.

I have an observable isSignedIn$ that returns something when the user is signed in. Now I want to simply hide a div with something like

<div *ngIf="!isSignedIn$"> content </div>

so that means the div is hidden when the user is not signed in/when nothing comes from the observable.

Upvotes: 1

Views: 1509

Answers (1)

izik
izik

Reputation: 1043

<div *ngIf="!(isSignedIn$ | async)"> content </div>

you need to use the async pipe

you can read more about it here: https://angular.io/api/common/AsyncPipe

Upvotes: 7

Related Questions