Ionic 3 无法将 filter() 结果转换为数组

Ionic 3 cannot convert filter() result into array

我有初始数据数组 dataToDisplay 和我需要向其中添加过滤数组的数组 dataToDisplay。我用 .filter() 这样做:

this.dataToDisplay = this.dataToDisplay.filter((res)=>{
  console.log(res);
  if(res.type==this.filterArray['typeOfIns'])
  {
    this.dataToFilter = res;
    console.log(this.dataToFilter)

    //this.dataToFilter = res;
    //console.log(this.dataToFilter)
  }

})

我收到一条错误消息:

ERROR Error: Error trying to diff '[object Object]'. Only arrays and iterables are allowed

第 58 行的结果:console.log(this.dataToFilter) 正在返回正确的数组,但无法显示和绑定到页面中。

dataToDisplay 具有以下结构:

dataToDisplay = [
    {id:.., type:.., name:..},
    {id:.., type:.., name:..}
]

请尝试以下代码:

this.dataToDisplay = this.dataToDisplay.filter((res)=>{
  return res.type==this.filterArray['typeOfIns']
})

这将完成所有工作。