Linking an existing filter inside a custom filter?

I have a custom filter that uses a filter number

and a custom filter partspermillion

that adds "ppm" at the end. I am currently linking my filters i.e. input | number | partspermillion

... However I find it long to input, I want my custom filter to use the number filter every time. The code looks like this:

.filter('partspermillion', function() {
    return function (input) {
        return input + 'ppm';
    }
})

      

+3


source to share


1 answer


Call the existing filter from the new filter using the $ filter service.



   .filter('partspermillion', function($filter) {
        return function (input) {
            return $filter('number')(input) + 'ppm';
        }
    })

      

+5


source







All Articles