2

Everywhere I can find says that you only need to declare it in the module file what am I missing? If anyone needs more information I can add whatever is needed

Pipe file:

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

@Pipe({
  name: 'partnersearch'
})
export class PartnerPipe implements PipeTransform {

    transform(value: any, args?: any): any {
        if (value.startsWith("::ffff:")) value = value.slice(7);
        return value;
    }

}

module.ts file (they are in the same folder):

import { PartnerPipe } from './partner.pipe';

@NgModule({
imports: [],
declarations: [
    PartnerPipe
]})

html:

{{ partner | partnersearch }}
amedeiros
  • 167
  • 3
  • 13

2 Answers2

3

You should also export it if it is in a shared module.

import { PartnerPipe } from './partner.pipe';

@NgModule({
  declarations: [
    PartnerPipe 
  ],
  exports: [
    PartnerPipe
  ]
})   
Ulrich Dohou
  • 1,509
  • 14
  • 25
2

You need to declare it in the module so that the components can use it.

import { NgModule } from '@angular/core';
import { PartnerPipe } from './partner.pipe';

@NgModule({
  declarations: [PartnerPipe],
})
export class MyModule {}
Teddy Sterne
  • 13,774
  • 2
  • 46
  • 51