How to use a pipe in two different Angular Modules

user6123723

I have a pipe

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

I have two modules in which I need to use this. If I do something like this in both the modules, I get an error saying that "two modules declare KeysPipe"

Module1, Module2:

declarations: [KeysPipe],

I then tried exporting KeysPipe through it's own module so that I can import it in to the two modules in which I need to use it

@NgModule({
    declarations: [ KeysPipe],
})
export class KeysPipeModule {
}

Now I'm importing the KeysPipeModule in the two modules I need to use KeysPipe

Module1, Module2:

imports: [KeysPipeModule],

But now I get a different template error saying that the pipe isn't found "The pipe 'keys' could not be found ("v *ngIf="docalc">"

Filip Lauc

You're on the right track the only thing your code is missing is the export in the KeysPipeModule. This is what it should look like:

@NgModule({
    declarations: [ KeysPipe],
    exports: [KeysPipe]
})
export class KeysPipeModule {}

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Java

How to declare a pipe globally to use in different modules?

From Dev

How to use two AngularJS services with same name from different modules?

From Dev

How to make two different modules in Android Studio use different versions of the same library via Gradle

From Dev

How to make two different modules in Android Studio use different versions of the same library via Gradle

From Dev

How to use a pipe in a component in Angular 2?

From Dev

how to use pipe in angular 2 js?

From Dev

How to use the angular decimal pipe in typscript

From Dev

How to inject environment config to different Angular Modules?

From Dev

How to use custom error handler service across different modules in angular2

From Dev

How to pass data between different modules using service having two different controller with different modules?

From Dev

How to merge and pipe results from two different commands to single command?

From Dev

How to use modules in modules

From Dev

How to use a Pipe between two processes in Process.Start

From Dev

How to put two charts on the same page with different modules?

From Dev

How to put two charts on the same page with different modules?

From Dev

How to use two different index variables inside the same ngFor in Angular 4

From Dev

How to use getters and setters in two different classes

From Dev

How to use two filters in stream for different transformations

From Dev

how to use ListView class for two different templates

From Dev

How to use two different records from database?

From Dev

How to use cat in a pipe

From Dev

Angular injection from different modules

From Dev

Angular injection from different modules

From Dev

How to pipe to bash as a different user

From Dev

How to use two different compilers for different targets in a .cabal file?

From Dev

How to use relative urls in angular 1.5 across all modules

From Dev

How can I use fallback js with angular modules?

From Dev

What happens if two android modules of the same android project use different support library versions?

From Dev

What happens if two android modules of the same android project use different support library versions?

Related Related

  1. 1

    How to declare a pipe globally to use in different modules?

  2. 2

    How to use two AngularJS services with same name from different modules?

  3. 3

    How to make two different modules in Android Studio use different versions of the same library via Gradle

  4. 4

    How to make two different modules in Android Studio use different versions of the same library via Gradle

  5. 5

    How to use a pipe in a component in Angular 2?

  6. 6

    how to use pipe in angular 2 js?

  7. 7

    How to use the angular decimal pipe in typscript

  8. 8

    How to inject environment config to different Angular Modules?

  9. 9

    How to use custom error handler service across different modules in angular2

  10. 10

    How to pass data between different modules using service having two different controller with different modules?

  11. 11

    How to merge and pipe results from two different commands to single command?

  12. 12

    How to use modules in modules

  13. 13

    How to use a Pipe between two processes in Process.Start

  14. 14

    How to put two charts on the same page with different modules?

  15. 15

    How to put two charts on the same page with different modules?

  16. 16

    How to use two different index variables inside the same ngFor in Angular 4

  17. 17

    How to use getters and setters in two different classes

  18. 18

    How to use two filters in stream for different transformations

  19. 19

    how to use ListView class for two different templates

  20. 20

    How to use two different records from database?

  21. 21

    How to use cat in a pipe

  22. 22

    Angular injection from different modules

  23. 23

    Angular injection from different modules

  24. 24

    How to pipe to bash as a different user

  25. 25

    How to use two different compilers for different targets in a .cabal file?

  26. 26

    How to use relative urls in angular 1.5 across all modules

  27. 27

    How can I use fallback js with angular modules?

  28. 28

    What happens if two android modules of the same android project use different support library versions?

  29. 29

    What happens if two android modules of the same android project use different support library versions?

HotTag

Archive