Seconds Timmer in Angular Typescript

Primarily Timmer is used for OTP Resend Option or Any action done before timeout.

So, It should Work Perfectly, Below is one of the easier ways for timmer in Angular, We use it from component means by typescript.

interval;
timmer(){   
  let timeLeft: number=20;  
    this.interval = setInterval(() => {
      if(timeLeft > 1) {
        timeLeft--;  
      } else {  
        clearInterval(this.interval);
        console.log("Timmer ended")
      }
    },1000) 
}

In the Above Function basically, we are creating an interval that will work until we clear it.

As above it will only show the timmer if the lefttime is greater than 1 sec.

Sign In or Register to comment.