The pipe ' ' could not be found angular2 custom pipe

后端 未结 9 1133
时光说笑
时光说笑 2020-11-27 14:33

I can\'t seem to fix this error. I have a search bar and an ngFor. I am trying to filter the array using a custom pipe like this:



        
9条回答
  •  忘掉有多难
    2020-11-27 14:51

    I have created a module for pipes in the same directory where my pipes are present

    import { NgModule } from '@angular/core';
    ///import pipe...
    import { Base64ToImage, TruncateString} from './'  
    
       @NgModule({
            imports: [],
            declarations: [Base64ToImage, TruncateString],
            exports: [Base64ToImage, TruncateString]
        })
    
        export class SharedPipeModule { }   
    

    Now import that module in app.module:

    import {SharedPipeModule} from './pipe/shared.pipe.module'
     @NgModule({
         imports: [
        ...
        , PipeModule.forRoot()
        ....
      ],
    

    Now it can be used by importing the same in the nested module

提交回复
热议问题