Ionic-3 Can't find Pipe

半城伤御伤魂 提交于 2019-11-28 10:50:06

so I fixed this issue by making a PipesModule where I import my custom Pipes into, then import it in the page module.ts that I wanna use it on

import { NgModule } from '@angular/core';
import { StripHTML } from './strip-html';

@NgModule({
  declarations: [
    StripHTML,
  ],
  imports: [

  ],
  exports: [
    StripHTML
  ]
})
export class PipesModule { }

and then in the page | HomePage as an example:

import { NgModule } from '@angular/core';
import { IonicPageModule } from 'ionic-angular';
import { Home } from './home';

import { PipesModule } from '../../pipes/pipes.module';

@NgModule({
  declarations: [
    Home,
  ],
  imports: [
    IonicPageModule.forChild(Home),
    PipesModule
  ],
  exports: [
    Home
  ]
})
export class HomeModule { }

and it did work fine , not sure if this is the correct way or not , but it worked fine, please let me know if there is a better way... thanks!

Foram Sangani

What you need to do is just import the PipesModule(line 12 in below snippet) in to your every page.module.ts (i.e. home.moodule.ts) file....

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

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

This worked for me.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!