Angular.ITacademy.dk
on Filters

Filters

https://docs.angularjs.org/guide/filter

// The need to capitalize the first letter of each word using filter('capitalize')

(function() {
    'use strict';

    angular
        .module('myApp.filters')
        .filter('capitalize', capitalize);

    function capitalize() {
        return filter;

        function filter(input) {
            if (input !== null) {
                return input.replace(/\w\S*/g, function(txt) {
                    return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
                });
            }
        }
    }
 })();

More Filters: