Angular 角度,错误类型错误:items.filter不是函数

Angular 角度,错误类型错误:items.filter不是函数,angular,angular5,Angular,Angular5,我在浏览器控制台中有这样一个错误: ERROR ERROR:Uncaught(承诺中):TypeError:items.filter不是函数 TypeError:items.filter不是函数 在FilterByFieldPipe.push../src/app/pipes/filter-by-field.ts.FilterByFieldPipe.transform(按字段过滤。ts:11) 位于TaskListComponent.push../src/app/components/tasks/

我在浏览器控制台中有这样一个错误:

ERROR ERROR:Uncaught(承诺中):TypeError:items.filter不是函数
TypeError:items.filter不是函数
在FilterByFieldPipe.push../src/app/pipes/filter-by-field.ts.FilterByFieldPipe.transform(按字段过滤。ts:11)
位于TaskListComponent.push../src/app/components/tasks/list.ts.TaskListComponent.refreshPipes(list.ts:139)
位于TaskListComponent.push../src/app/components/tasks/list.ts.TaskListComponent.refreshttasks(list.ts:129)
在名单上。ts:29
在ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke(zone.js:388)
在Object.onInvoke上(core.js:3654)
........
从这个文件

从'@angular/core'导入{Pipe,PipeTransform};
@烟斗({
名称:'filterByField',
纯:假
})
导出类FilterByFieldPipe实现PipeTransform{
转换(项、键、值){
若有(项目){
返回项目。过滤器((项目)=>项目[键]==值);
}
}
}
元素被创建,我可以看到它们,问题是它们不是一起输出的

这是模型文件:

app.module.ts

从'@angular/platform browser'导入{BrowserModule};
从“@angular/core”导入{NgModule};
进口{
反应形式模块,
FormsModule,
造模工,
FormGroup,
验证器
}从“@angular/forms”开始;
从'@angular/http'导入{HttpModule};
从“../environments/environment”导入{environment};
从“./APP.CONFIG”导入{APP_CONFIG,appConfig};
从“/app.routes”导入{AppRoutingModule};
从“./services/auth”导入{AuthService};
从“./services/task”导入{TaskService};
从“./components/app”导入{AppComponent};
从“./components/login”导入{LoginComponent};
从“./components/navbar”导入{NavbarComponent};
从“./components/inline edit”导入{InlineEditComponent};
从“./components/registration”导入{RegistrationComponent};
从“./components/confirm email”导入{confirmeailcomponent};
从“./components/admin”导入{AdminComponent};
从“./components/tasks”导入{TasksComponent};
从“./components/tasks/list”导入{TaskListComponent};
从“./components/tasks/form”导入{TaskFormComponent};
从“./components/tasks/detail”导入{TasksDetailComponent};
从“./components/tasks/detailinline”导入{TasksDetailInlineComponent};
从“./components/tasks/edit”导入{TaskEditComponent};
从“angular2通知”导入{SimpleNotificationsModule};
从“mydatepicker”导入{MyDatePickerModule};
//从'@ng bootstrap/ng-bootstrap'导入{NgbModule};
导入“/rxjs扩展名”;
从“@angular/platform browser/animations”导入{BrowserAnimationsModule};
@NGD模块({
声明:[
应用组件,
LoginComponent,
注册组件,
确认邮件组件,
导航组件,
AdminComponent,
任务组件,
任务列表组件,
TaskFormComponent,
任务组件,
TasksDetailLineComponent,
InlineEditComponent,
TaskEditComponent
],
进口:[
浏览器模块,
反应形式模块,
FormsModule,
HttpModule,
批准模块,
SimpleNotificationsModule.forRoot(),
BrowserAnimationsModule,
MyDatePickerModule/*,
NgbModule.forRoot()*/
],
供应商:[
AuthService,
任务服务,
造模工,
验证器,
{提供:APP_CONFIG,使用工厂:appConfig}
],
引导:[AppComponent]
})
导出类AppModule{}

if
语句中添加一个检查项是否等于数组。如果没有它,当您在错误类型的数据上使用管道时,将收到错误消息

您可以通过比较
items.constructor===Array
或只添加
items:Array
来实现


我建议您升级项目的版本。由于项目版本太旧,您正在寻找或将要寻找的许多答案可能不适用于您。

您可以共享您的数据模型吗?您可以用控制台记录项目的价值吗。似乎这不是一个数组,因此它上不存在筛选函数。模型!=模块。我们目前无法看到您如何使用什么调用管道,因此不清楚您为什么希望它是一个数组。请给出一个例子。确切地说,如果你能给我们提供一个在你的管道中使用的“项目”的例子,那将是很好的。