RPeraltaJr
12/8/2017 - 6:57 PM

Capitalize Filter

Capitalize the first letter of each word in a string

<h4> {{ post.title | capitalize }} </h4>
var vm = new Vue({
    el: '#root',
    data: function() {
        return {     
            // ...
        }
    },
    methods: {
      // ...
    },
    computed: {
      // ...
    },
    filters: {
        capitalize: function(value) {
            return value.replace( /\w\S*/g, function(txt) {
                return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
            });
        }
    }
});