I am using a pipe in angular to return a value. To use this pipe I need to declare this pipe in every lazy loaded module. I am using this pipe with shared module. But I think this is not good practice to import pipemodule in every module file to use this. Is there any best method? Here is live example link https://stackblitz.com/edit/angulattesting
Asked
Active
Viewed 457 times
3
-
Not guaranteed it's enough. If you have `@pipe` in (let's say) `PipesModule`, then importing `PipesModule` into the main module (let's call it `AppModule`) might allow all submodules to see it. – Gynteniuxas Oct 12 '20 at 08:48
-
Gytis TG I think u talk about share Module. – Hasnat Hameed Oct 12 '20 at 09:32
-
This depends from project to project. This name also fits if your pipe is in there. I believe we used something similar as well but can't quite remember if this is all what's needed. Have you tried this? Does it work? – Gynteniuxas Oct 12 '20 at 09:42
-
I have made a pipeModule and import this in appmodule but it is not working for other module. – Hasnat Hameed Oct 12 '20 at 09:53
-
Try checking this one: https://stackoverflow.com/questions/40219666/global-pipe-in-angular-2?rq=1 If it's not working, can you provide a working demo example (on stackblitz, for example)? – Gynteniuxas Oct 12 '20 at 09:58
-
https://stackblitz.com/edit/angulattesting this is live example link. this works with shared module. But I wanna use better method I think this is not good practice. – Hasnat Hameed Oct 13 '20 at 10:24
-
What approach would be considered as a good practice? I don't know, maybe I'm also following bad practice :d – Gynteniuxas Oct 14 '20 at 05:24
1 Answers
0
The solution is shared module. https://stackblitz.com/edit/angulattesting but I think this is not best approach.

Hasnat Hameed
- 111
- 8