Seeking assistance with setInterval() in my Angular project
Here is the code snippet:
recordingTimer: any = '00:00:00';
timer: boolean = true;
recording(){
////// Add recording meeting functionality here
if (this.timer) {
let seconds = 0;
let minutes = 0;
let hours = 0;
seconds += 1;
if (seconds >= 60) {
seconds = 0;
minutes += 1
if (minutes >= 60) {
minutes = 0;
hours += 1
}
}
/// Update recording time
this.recordingTimer = (hours ? (hours > 9 ? hours : "0" + hours) : "00") + ":" + (minutes ? (minutes > 9 ? minutes : "0" + minutes) : "00") + ":" + (seconds > 9 ? seconds : "0" + seconds);
console.log(this.recordingTimer)
}
}
repeat() {
setInterval(() => this.recording(), 1000);
}
Why is the console.log statement repeating with the same value of "00:00:01"?
Please provide guidance. Thank you.