2016-10-27 11 views
0

を使用して、私は新しいパイプを作成しました:また、ここ角度2は、カスタムパイプ

import { ReversePipe } from '../reverse.pipe'; 

import { Pipe, PipeTransform } from '@angular/core'; 

@Pipe({ 
    name: 'reverse' 
}) 
export class ReversePipe { 
    transform(arr) { 
    var copy = arr.slice(); 
    return copy.reverse(); 
    } 
} 

は私のコンポーネントでそれをインポート

pipes: [ReversePipe] 

を、私は私のアプリを実行すると私は得る

The pipe 'reverse' could not be found 

私は何が欠けていますか?あなたはパイプに

import { ReversePipe } from '../reverse.pipe';

を使用すると、その後の宣言に

NgModule({ 
declarations: [ 
     <...>, 
     ReversePipe 
    ] 

これは、テンプレートのコンパイルの名前を使用可能にするモジュールで

答えて