Angular 如何在Ionic2-A2项目上使用自定义管道?

Angular 如何在Ionic2-A2项目上使用自定义管道?,angular,filter,ionic2,pipe,Angular,Filter,Ionic2,Pipe,我想用管道过滤一个由*ngFor生成的简单列表。 这是我的相关树文件夹: src |_app |_app.component.ts |_app.module.ts |_pages |_home.ts |_home.html |_pipes |_pipe.ts 这是我的密码: 我的烟斗。ts:(只是一个普通的烟斗) 我的家.ts(显示的唯一页面) 我的主页模板(home.html) 主页 {{post.data.title} 要继续,我基本

我想用管道过滤一个由*ngFor生成的简单列表。 这是我的相关树文件夹:

src
 |_app
    |_app.component.ts
    |_app.module.ts
 |_pages
     |_home.ts
     |_home.html
 |_pipes
     |_pipe.ts
这是我的密码:

我的烟斗。ts:(只是一个普通的烟斗)

我的家.ts(显示的唯一页面)

我的主页模板(home.html)


主页
{{post.data.title}
要继续,我基本上是在pipe.ts中声明一个管道,在home.ts中导入它并在home.html中显示它,但它返回以下错误:

类型为“{selector:string;templateUrl:string;pipes:any[];}”的参数不能分配给类型为“Component”的参数。对象 文字只能指定已知的属性,“管道”不存在 在“组件”类型中

是否有任何选项可以声明我缺少的更多@Component属性? 成功添加导入后,我将能够在列表的每个项目上使用它

显示
@组件的元数据属性列表
,并且
管道
确实不在其上。管道是一种声明,您应该通过模块而不是组件提供它。显示
@组件的元数据属性列表
,并且
管道
确实不在其上。管道是一种声明,您应该通过模块而不是组件提供它。
import {Pipe} from "angular2/core";

@Pipe({
    name:"search"
})

export class SearchPipe{
    transform(value){
        return value;
    }
}
import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
import { Http } from '@angular/http';
import { SearchPipe } from '../pipes/search-pipes';

import 'rxjs/add/operator/map';


@Component({
  selector: 'page-home',
  templateUrl: 'home.html',
  pipes:[SearchPipe] //Here is where i got the error
})
export class HomePage {

  posts: any;


  constructor(public navCtrl: NavController, public http: Http) {

    this.http.get('https://www.reddit.com/r/gifs/new/.json').map(
      res => res.json()).subscribe(data => {
        this.posts = data.data.children;
      });

  }
}
<ion-header>
  <ion-navbar>
    <ion-title>Home Page</ion-title>
  </ion-navbar>
</ion-header>

<ion-content>
  <ion-list>
    <ion-item *ngFor="let post of posts | search">
      <h2>{{post.data.title}}</h2>
      <img [src]="post.data.url" />
    </ion-item>
  </ion-list>
</ion-content>