“Temporizador en Angular 8” Código de respuesta

Cómo hacer un temporizador angular

timeLeft: number = 60;
  interval;

startTimer() {
    this.interval = setInterval(() => {
      if(this.timeLeft > 0) {
        this.timeLeft--;
      } else {
        this.timeLeft = 60;
      }
    },1000)
  }

  pauseTimer() {
    clearInterval(this.interval);
  }

<button (click)='startTimer()'>Start Timer</button>
<button (click)='pauseTimer()'>Pause</button>

<p>{{timeLeft}} Seconds Left....</p>
|_Genos_|

Temporizador en Angular 8

timeLeft: number = 60;
  interval;

startTimer() {
    this.interval = setInterval(() => {
      if(this.timeLeft > 0) {
        this.timeLeft--;
      } else {
        this.timeLeft = 60;
      }
    },1000)
  }

  pauseTimer() {
    clearInterval(this.interval);
  }
    
<button (click)='startTimer()'>Start Timer</button>
<button (click)='pauseTimer()'>Pause</button>

<p>{{timeLeft}} Seconds Left....</p>
Dinesh Shrestha

Respuestas similares a “Temporizador en Angular 8”

Preguntas similares a “Temporizador en Angular 8”

Más respuestas relacionadas con “Temporizador en Angular 8” en JavaScript

Explore las respuestas de código populares por idioma

Explorar otros lenguajes de código