How to call one filter from another filter in angular.js

后端 未结 5 1601
傲寒
傲寒 2020-12-14 14:57

I have a filter, linkifyStuff, in which I want some variables processed using another filter. I can\'t figure out the syntax to call one filter from another.

I know

5条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-14 15:13

    app.filter('linkifyStuff', function(sanitizeStuffFilter,prettifyStuffFilter) {
        return function(text) {
    
            return sanitizeStuffFilter(text) + ' whatever ' + prettifyStuffFilter(text);
        }
    });
    

    this didnt work out for me. if anyone has problem with the above code. you can try this which worked out for me pretty well.

    app.filter('linkifyStuff', function($filter) {
            return function(text) {
    
                return $filter('sanitizeStuffFilter')(text) + ' whatever ' + $filter('prettifyStuffFilter')(text);
            }
        });
    

提交回复
热议问题