THE SITUATION:
I need to use a pipe in only one component. For this reason i didn't wanted to import it globally but only in the component.
I have tried looking for reference on how to do it but couldn't find it.
This is my attempt:
THE PIPE:
when tested globally is working fine
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({name: 'keys'})
export class KeysPipe implements PipeTransform {
transform(value, args:string[]) : any
{
let keys = [];
for (let key in value)
{
keys.push({key: key, value: value[key]});
}
return keys;
}
}
THE COMPONENT:
import { Component, NgModule } from '@angular/core';
import { NavController, NavParams } from 'ionic-angular';
import {CommonModule} from "@angular/common";
import { KeysPipe } from './keys.pipe';
@Component({
selector: 'page-attendees',
templateUrl: 'attendees.html'
})
@NgModule({
declarations: [ KeysPipe ],
imports: [ CommonModule ],
exports: [ KeysPipe ]
})
export class AttendeesPage {
public attendeeList = [];
public arrayOfKeys;
constructor(
public navCtrl: NavController,
public navParams: NavParams
) {
this.attendeeList = this.navParams.get('attendeeList');
this.arrayOfKeys = Object.keys(this.attendeeList);
}
ionViewDidLoad() {
console.log('AttendeesPage');
}
}
THE ERROR:
Unhandled Promise rejection: Template parse errors:
The pipe 'keys' could not be found
PLUNKER:
https://plnkr.co/edit/YJUHmAkhAMNki2i6A9VY?p=preview
THE QUESTION:
Do you know what I am doing wrong or if I am missing something?
Thanks!