How to create and call a pipe from the component in Angular 2?

后端 未结 5 764
臣服心动
臣服心动 2020-12-17 15:03

I want to create a dynamic pipe which I am going to call from the component.

import {Component, Pipe, PipeTransform} from \'angular2/core\';

@Pipe({ name: \         


        
5条回答
  •  半阙折子戏
    2020-12-17 15:56

    I just wanted to add to @pasha-oleynik answer. Angular 2+ including Ionic 2+ all expect the pipe to be declared in the module:

    @NgModule({
        declarations: [
            AppComponent ,
            filter
        ]
    

    Also this is the only place that the pipe needs to be declared. There is no longer a pipe property under a module or component.

提交回复
热议问题