Reputation: 167
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 }}
Upvotes: 2
Views: 1191
Reputation: 1559
You should also export it if it is in a shared module.
import { PartnerPipe } from './partner.pipe';
@NgModule({
declarations: [
PartnerPipe
],
exports: [
PartnerPipe
]
})
Upvotes: 3
Reputation: 14201
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 {}
Upvotes: 2