I am using angularjs timer to build a countdown display.
The timer directive returns value of hours, minutes and seconds as integer. Means, 1,2,3,.... But I want to display these values as 2 digits. like, 01,02,03,04,......
Is there any filter or directive to accomplish this?
I would like to create a simple custom AngularJS filter.
Filters are used for formatting data displayed to the user.
Usage
{{value | counterValue}}
Filter
app.filter('counterValue', function(){
return function(value){
value = parseInt(value);
if(!isNaN(value) && value >= 0 && value < 10)
return "0"+ valueInt;
return "";
}
})