dmh
dmh

Reputation: 430

Custom Pipe Ionic 3 | Pipe Not Found

I need help, I have problem with pipe in Ioni 3, I've been following this thread Ionic 3 cant find Pipe and this link Ionic 3 Pipe Globally But still no luck all i Get is The Pipe separator not work, I'm generating my pipe using ionic g pipe separator I use my pipe like this in my html

{{string | separator}}

my separator.ts (custom pipe)

import { Pipe, PipeTransform } from '@angular/core';

/**
 * Generated class for the SeparatorPipe pipe.
 *
 * See https://angular.io/api/core/Pipe for more info on Angular Pipes.
 */
@Pipe({
  name: 'separator',
})
export class SeparatorPipe implements PipeTransform {
  /**
   * Takes a value and makes it lowercase.
   */
  transform(value: string, ...args) {
    return value.toLowerCase();
  }
}

my pipe.module.ts

import { NgModule } from '@angular/core';
import { SeparatorPipe } from './separator/separator';
@NgModule({
    declarations: [SeparatorPipe],
    imports: [],
    exports: [SeparatorPipe]
})
export class PipesModule {}

my page.module.ts

import { NgModule } from '@angular/core';
import { IonicPageModule } from 'ionic-angular';
import { InfaqPage } from './infaq';
import { PipesModule } from '../../pipes/pipes.module';

@NgModule({
  declarations: [
    InfaqPage,
  ],
  imports: [
    IonicPageModule.forChild(InfaqPage),
    PipesModule
  ],
})
export class InfaqPageModule {}

Any idea why it doesnt work??

Image Eror Pipe Ionic 3

Upvotes: 4

Views: 6123

Answers (1)

Paresh Gami
Paresh Gami

Reputation: 4792

Step 1: ionic g pipe separator

Here ionic generator src/pipes/pipes.module.ts => Delete that file.

Step 2: Import pipe in app.module.ts file

import { SeparatorPipe } from '../pipes/separator/separator';

declarations: [
    ...
    SeparatorPipe
    ...
  ],

Step 3: Just use pipe in page like

{{'STACKOVERFLOW' | separator}}

Upvotes: 11

Related Questions