Ionic-3 Can't find Pipe

后端 未结 2 2070
暗喜
暗喜 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!

    0 讨论(0)
  • 2020-12-10 12:51

    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.

    0 讨论(0)
提交回复
热议问题