3

I have to iterate over an object keys inside a template, so I made this custom pipe :

import {PipeTransform, Pipe} from "@angular/core";

@Pipe({name: "keys"})
export class KeysPipe implements PipeTransform {
  transform(value: any, args?: any[]): any[] {
    return Object.keys(value);
  }
}

And inside my page it's imported as follow :

import {KeysPipe} from "../../pipes/keys-pipe";
import {Component} from '@angular/core';
@Component({
  selector: 'page-history',
  templateUrl: 'history.html',
  pipes: [ KeysPipe ]
})
export class HistoryPage {}

But when i build project there is this error that occurs :

Argument of type '{ selector: string; templateUrl: string; pipes: typeof KeysPipe[]; }' is not assignable to parameter of type 'Component'. Object literal may only specify known properties, and 'pipes' does not exist in type 'Component'.

Any idea ? I didn't declare it in app.module.ts nor app.component.ts. Thanks.

Senorihl
  • 312
  • 2
  • 16

1 Answers1

4

There is no pipes in @Component() anymore since quite some time.

Now it's

@NgModule({
  declarations: [ KeysPipe ]

See also Select based on enum in Angular2

Community
  • 1
  • 1
Günter Zöchbauer
  • 623,577
  • 216
  • 2,003
  • 1,567