Hello Everyone, In this article I am sharing how to display Month Name for corresponding number such as if we have month coming in number from server say(1,2...so on) and we want to display January in place of 1, February in place of 2 and so on by angular.js. We can try this:
<html>
<span>
{{user.birthDate}}, {{user.birthMonth | monthName}}
</span>
</html>
<script>
phonecatApp.filter('monthName', [function() {
return function (monthNumber) { //1 = January
var monthNames = [ 'January', 'February', 'March', 'April', 'May', 'June',
'July', 'August', 'September', 'October', 'November', 'December' ];
return monthNames[monthNumber - 1];
}
}]);
</script>
0 Comment(s)