Having trouble formatting the input value. Take a look at this code snippet:
<input
type="text"
class="form-control"
name="time"
formControlName="time"
(input)="convertToMinute($event.target.value)"
/>
Here is the function in question:
convertToMinute(value: string) {
console.log(value);
let minute = value.slice(0, 2);
let seconds = value.slice(2, 4);
let result = minute + ":" + seconds;
console.log(result);
}
The issue occurs when entering 500, resulting in 50:0 instead of 05:00. How can this be fixed?