ivanao
ivanao

Reputation: 235

Angular 12 Use pipe from component

Hello I have problems to use from a component in Angular 12 (from the view if it works).

It is a pipe that I installed, although I have already tried with several and the same thing happens.

Specifically, it is this https://www.npmjs.com/package/@josee9988/filter-pipe-ngx

I do this:

app.module.ts

..

import { FilterModule } from '@josee9988/filter-pipe-ngx';
..

imports: [FilterModule],
..

providers: [FilterModule],
..

Y en comp1.component.ts

import { FilterModule } from '@josee9988/filter-pipe-ngx';

..

constructor(private FilterModule_: FilterModule) { }

..

funcion1 () {
   this.v1 = this.FilterModule_.transform(this.v2, "gfg", v3);
}

..

And he tells me that "error TS2339: Property 'transform' does not exist on type 'FilterModule'"

And it won't even let me use ng serve.

Thank.

Best regards.

Upvotes: 3

Views: 5132

Answers (1)

Yan Koshelev
Yan Koshelev

Reputation: 1129

You trying to inject a module, but you need a pipe.

constructor(private filterPipe: FilterPipe) { }
...
this.filterPipe.transform(...)

If you will catch NullInjector just provide FilterPipe in the module.

providers: [FilterPipe]

Upvotes: 7

Related Questions