0

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

7
  • 1
    and what is the question? Commented Jun 3, 2022 at 4:29
  • @TheFabio Whenever the elevator reaches the first floor, store the date and display it in dd/MM/yy format. Commented Jun 3, 2022 at 4:30
  • @TuNguyen I tried, there is even what I wrote there and I tried a lot It just does not work for me Commented Jun 3, 2022 at 4:35
  • @TuNguyen I can not convert the Observable <Number> to a number Commented Jun 3, 2022 at 4:35
  • you don't convert it... you should subscribe to the observable Commented Jun 3, 2022 at 4:40

1 Answer 1

1

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;
      });
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.