Global pipe in Angular 2

前端 未结 1 1649
臣服心动
臣服心动 2021-01-05 09:40

I want to make a pipe available in all the app. Acording with what I read in the Angular docs and internet, if I declare a pipe into the root module declaratios, it make\'s

相关标签:
1条回答
  • 2021-01-05 10:34

    You need to add the module that contains the pipe (and has it in declarations: [] and exports: []) to imports: [...] of your current module, then it's available in the current module.

    @NgModule({
      imports:      [ CommonModule],
      declarations: [ TranslatePipe],
      exports:      [ TranslatePipe],
    })
    export class TranslateModule { }
    
    @NgModule({
      imports:      [ CommonModule, TranslateModule],
      declarations: [ NavbarMenuComponent]
    })
    export class NavbarModule { }
    
    0 讨论(0)
提交回复
热议问题