Home > other >  Angular: Use Pipe to Format Date
Angular: Use Pipe to Format Date

Time:06-03

I have an elevator component. Whenever the elevator reaches the first floor, store the date and display it in dd/MM/yy format.

if floor === 1 show Date
else
return(empty)

My stackblitz

CodePudding user response:

You cannot convert an observable to a number...

you need to subscribe to it:

interval(1000)
      .pipe(map(() => Math.floor(Math.random() * 3)   1))
      .subscribe((floor) => {
        this.floor = floor;
      });
  • Related