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 }}
8
  • 1
    Possible duplicate of Angular2: custom pipe could not be found Commented Jun 15, 2018 at 18:01
  • Possible duplicate of Angular custom pipe not be found Commented Jun 15, 2018 at 18:01
  • Is it in a shared module ? Commented Jun 15, 2018 at 18:07
  • possible duplicate comment. I've already tried both of those with no luck. Also the angular 2 one uses an extra file which I dont Commented Jun 15, 2018 at 18:07
  • Yes it is in a shared module Commented Jun 15, 2018 at 18:08

2 Answers 2

3

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

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

@NgModule({
  declarations: [
    PartnerPipe 
  ],
  exports: [
    PartnerPipe
  ]
})   
Sign up to request clarification or add additional context in comments.

Comments

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 {}

1 Comment

@amedeiros so make sure to post everything required

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.