Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

How to do a timer 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>
Comment

timer in 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>
Comment

PREVIOUS NEXT
Code Example
Javascript :: split text javascript 
Javascript :: decrementar en java 
Javascript :: tooltipster on dynamic content 
Javascript :: set token to expiration with passport jwt. 
Javascript :: js retry function if error 
Javascript :: loop through elements by name js 
Javascript :: how to delete current clicked item in array react 
Javascript :: practice javascript 
Javascript :: ejs tutorial 
Javascript :: Connect node.js with react.js 
Javascript :: js set css 
Javascript :: js remove trailling lines 
Javascript :: using javascript array create bootstrap card 
Javascript :: how to link prototypes in js using call method 
Javascript :: custom hook 
Javascript :: sequelize exclude attributes 
Javascript :: back button not working when modal open in react native 
Javascript :: alert by code stackoverflow 
Javascript :: push notification react native 
Javascript :: How to Check for an Empty String in JavaScript by String Comparison 
Javascript :: javascript true string to boolean 
Javascript :: get field type file js and loop 
Javascript :: window close function in javascript 
Javascript :: express alternatives 
Javascript :: react duration picker 
Javascript :: less than equal to in javascript 
Javascript :: d3.js onclick event 
Javascript :: textinput onpress react native 
Javascript :: empty the integer array javascript 
Javascript :: event delegation javascript 
ADD CONTENT
Topic
Content
Source link
Name
5+6 =