angular declaring pipe in more than one component

Solutions on MaxInterview for angular declaring pipe in more than one component by the best coders in the world

showing results for - "angular declaring pipe in more than one component"
Jacobo
25 Mar 2016
11) Firstly, create pipes folder in src/app folder (in app folder).
2
32) Second, on cmd "ng generate pipe pipes/searchfilter" => this will generate two files in pipes.
4
53 Third, create file in pipes folder with name "pipes.module.ts" and write below code to => "pipes.module.ts"
6
7import { NgModule } from '@angular/core';
8import { CommonModule } from '@angular/common';
9import { SearchfilterPipe } from './searchfilter.pipe';  //our pipe which we generate
10
11@NgModule({
12  imports: [
13    CommonModule
14  ],
15  declarations: [SearchfilterPipe],
16  exports: [SearchfilterPipe]
17})
18export class PipesModule { }
19Now we have PipesModule we can generate more pipes and write them in pipesmodule. We will import only PipesModule instead of all pipes.
20
214) You do not have to import PipesModule in app.module.ts
22
235) Now go to page which you want to use pipe and open for example "anasayfa.module.ts" and import "PipesModule" and write it in @ngModel imports(it will be created automatically) Please be careful you will import PipesModule to something.MODULE.TS not something.page.ts
24
25