Fraction size for AngularJS 1.2.x currency filter.

HTML

<section data-ng-app="test" data-ng-controller="TestController as vm">
    <p>This is a quick demonstration on how to extend the built-in functionality of AngularJS.</p>
    <p>Sometimes we must revert to using AngularJS v1.2.x for IE8 compatibility and then we lose the fraction size option within the currency filter.</p>
    <p>Thanks to Bart Meinders for taking our massively basic implementation and making it function more "the Angular way" by reusing the existing filters.</p>
    <p>It's quite an elegant implementation.</p>
    <p>Value: <span data-ng-bind="vm.testValue | currency: '£': 2"></span>
    </p>
</section>

JavaScript

(function (angular) {
    angular.module('test', [])
        .config(config)
        .controller('TestController', TestController);

    function config($provide) {

        function currencyFilter($delegate, numberFilter) {

            return function (amount, currencySymbol, fractionSize) {
                // Get the existing currency filter
                var currency = $delegate.apply($delegate, arguments);
                // Format the value with our chosen fraction size
                var fraction = numberFilter(amount, fractionSize);
                // Reformat the filtered value with our fraction size
                return currency.replace(/[0-9]+.*[0-9]+/, fraction);
            };
        }
        currencyFilter.$inject = ['$delegate', 'numberFilter'];

        $provide.decorator('currencyFilter', currencyFilter);
    }
    config.$inject = ['$provide'];

    function TestController() {

        var vm = this;

        vm.testValue = 15787000.45678;
    }
})(window.angular);