showing results for - "how to do a timer angular"
Ana
12 Jan 2018
1timeLeft: number = 60;
2  interval;
3
4startTimer() {
5    this.interval = setInterval(() => {
6      if(this.timeLeft > 0) {
7        this.timeLeft--;
8      } else {
9        this.timeLeft = 60;
10      }
11    },1000)
12  }
13
14  pauseTimer() {
15    clearInterval(this.interval);
16  }
17
18<button (click)='startTimer()'>Start Timer</button>
19<button (click)='pauseTimer()'>Pause</button>
20
21<p>{{timeLeft}} Seconds Left....</p>
22