Reputation: 27
I am trying to implement search functionality in my ionic app.
I installed ng2-search-filter by using:
npm i ng2-search-filter --save
I added it in page module file:
import { Ng2SearchPipeModule } from "ng2-search-filter";
@NgModule({
imports: [
CommonModule,
FormsModule,
IonicModule,
ServiziPageRoutingModule,
ComponentsModule,
Ng2SearchPipeModule,
]
I added a component in page app-fornitservizi and when I use the code in my component:
<ion-item
*ngFor="let item of data| filter: searchQuery.value"
lines="none"
>
I get error message:
ERROR Error: Uncaught (in promise): Error: The pipe 'filter' could not be found!
I am not able to figure it out what is the issue. I would like to know how can I use a pipe in a component while the component is in the page. If anyone knows then please let me know. Thanks
Upvotes: 0
Views: 3831
Reputation: 7119
Instead of page.module.ts file import ng2-search-filter into components.module.ts then it will work. Add following code in your components.module.ts file:
first import Ng2SearchPipeModule:
import { Ng2SearchPipeModule } from "ng2-search-filter";
Second add Ng2SearchPipeModule to imports in NgModule:
@NgModule({
imports: [
Ng2SearchPipeModule,
]
Upvotes: 2