Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to convert number into corresponding Month Name

    • 0
    • 1
    • 1
    • 1
    • 0
    • 0
    • 0
    • 0
    • 841
    Comment on it

    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)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: