$scope.timing = "1:2"; // Ex: "0.3", 10:1", "2:11", "11:41"
I want the above $scope.timing in 01:02 format.
How can i can achieve this?
You could use moment.js, as anshulk commented. this also is an opportunity to use a custom filter in the template
<div ng-bind="vm.timing | hhSSFilter"></div>
function hhSSfilter(input) {
var result = input.split(':').map(d => {
return d.length < 2 ? '0' + d : d;
});
return result.join(':');
}
11:41
1:2would output as01:02and not01:200.3fit in? Seems out of place01:02, it automatically takes correct timing when digit is above 10 i.e,11:41