Cannot create pipe in Angular 2 with ES5

I have a very simple pipe that follows the https://angular.io/guide/cheatsheet commands :

app.DisplayKeystrokePipe = ng.core
    .Pipe({
        name: "displayKeystroke"
    })
    .Class({
        transform: function() {

        }
    });

Sorry, I get an error: Error: Only Function or Array is supported in Class definition for key 'constructor' is 'undefined'

what am I doing wrong?

+4
source share
1 answer

You are missing a constructor in Class({})

app.DisplayKeystrokePipe = ng.core
    .Pipe({
        name: "displayKeystroke"
    })
    .Class({
        constructor : function() {}, // <<< ---
        transform: function() {

        }
    });

You can read decorators.ts what constructor is required.

+4
source

All Articles