我正在研究如何在 Angular2 中过滤数据数组。
我研究过使用自定义管道,但我觉得这不是我想要的,因为它似乎更适合简单的表示转换,而不是过滤大量数据。
数组排列如下:
getLogs(): Array<Logs> {
return [
{ id: '1', plate: 'plate1', time: 20 },
{ id: '1', plate: 'plate2', time: 30 },
{ id: '1', plate: 'plate3', time: 30 },
{ id: '2', plate: 'plate4', time: 30 },
{ id: '2', plate: 'plate5', time: 30 },
{ id: '2', plate: 'plate6', time: 30 }
];
}
我想通过 id 来过滤它。因此,当我在搜索栏中输入“1”时,它会更新以显示相应的值。
如果有一种方法可以做到这一点,我很想知道!