Search code examples
javascriptangularangular2-pipe

How to make custom Pipes in Angular 2/4 with Javascript (no typescript)


I want to make a custom pipe for my angular 4 application, but all of the resources I've found only show how to make pipes in TypeScript. I have to use JavaScript. Can anyone explain how to do this in JavaScript?


Solution

  • found it. From https://angular.io/docs/ts/latest/cookbook/ts-to-js.html

    app.MyPipe = ng.core.Pipe({
      name: 'myPipe'
    }).Class({
        constructor: function () {
        }, transform: function (input) {
            return input ? 'Yep' : 'Oh, I don't think so';
    
        }
    });