Ionic-3 Can't find Pipe

后端 未结 2 2105
暗喜
暗喜 2020-12-10 12:08

I have just upgraded to Ionic 3.0.1 so I can use LazyLoading , and since that I can\'t use my custom Pipes :

import {          


        
2条回答
  •  感动是毒
    2020-12-10 12:39

    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!

提交回复
热议问题