Currently, I have a timer that is counting down from a user-set value. Users input a number representing minutes, which is then converted to milliseconds by multiplying it by 1000 * 60. The timer then decrements this number as it counts down.
My goal is to display this countdown in the format of minutes and seconds. For example, if a user enters 3.5, it should be displayed as 03:30.
I attempted to use the date filter in Angular to achieve this formatting, but it seems to be out of sync with the timer value. It decrements once and then stops.
Here's the code snippet:
<h4 class="timer">{{ vm.timer.ticks | date: "mm:ss"}}</h4>
The timer functionality is within a service:
start(duration) {
this.ticks = duration;
this.timer = this.$interval(() => {
if (this.ticks === 0) return this.stop();
this.ticks--;
}, 1000);
}