I am building a countdown timer function in Angular that will keep executing every second. To call the function, I am using setInterval
. This will be used in a mobile app (Ionic).
setInterval(() => {
this.countdownTime = this.getCountDownTime(date1,date2);
console.log(this.countdownTime);
}, 1000);
Is this the correct way to update the time every second? Or, is there an efficient alternative?