Ng2SearchPipeModule filter causing error: Property 'filter' does not exist on type 'x.component'

1.6k Views Asked by At

I have implemented a filter/search functionality on tables in Angular 6. I'm using this ng-2-search-filter library.

The functionality works perfectly in the front-end, and causes no console errors.

When I run an ng build "--prod" the library is causing build errors in the output, everywhere I have used the filter.

Error:

Property 'filter' does not exist on type 'x.component'.

I've imported the library in the app.module.ts appservices and @ngModule imports.

The library is also in the package.json as version "ng2-search-filter": "^0.4.7".

The input for the filter on the html is as follows:

  <input type="text" class="form-control" [(ngModel)]="filter">

and used in the *ngFor as follows:

    <tr *ngFor="let item of items| filter:filter};">

The only solutions I can find are in relation to the RxJS filter. I've imported the library individually into each component that uses filter, but that has no impact.

2

There are 2 best solutions below

0
Stephen McGowan On

Sorry, the error lay in the component, I didn't initialize any variable 'filter', didn't realize I should have as no errors were thrown.

public filter: string;
0
Hatrox New On

I was facing the same issue. Just select 'save all' and re run your code. You will not get that error.