Angular 在Ionic 4中按日期分组事件
我在爱奥尼亚4有个问题,我想按日期安排一些活动。我读过,似乎用管道我可以做到这一点,但我不知道它是如何工作的 我的json如下所示:Angular 在Ionic 4中按日期分组事件,angular,sorting,ionic-framework,pipe,Angular,Sorting,Ionic Framework,Pipe,我在爱奥尼亚4有个问题,我想按日期安排一些活动。我读过,似乎用管道我可以做到这一点,但我不知道它是如何工作的 我的json如下所示: "clasesDB": [ { "estado": true, "_id": "5d9a90b21c9d440000c41909", "horaApertura": "2019-10-18T13:00:00.363Z", "horaCierre": "2
"clasesDB": [
{
"estado": true,
"_id": "5d9a90b21c9d440000c41909",
"horaApertura": "2019-10-18T13:00:00.363Z",
"horaCierre": "2019-10-18T14:00:00.363Z",
},
{
"estado": true,
"_id": "5d9adca55d091800171a7e27",
"horaApertura": "2019-10-18T18:00:00.363Z",
"horaCierre": "2019-10-18T19:00:00.363Z",
},
{
"estado": true,
"_id": "5d9adc9b5d091800171a7e26",
"horaApertura": "2019-10-19T19:00:00.363Z",
"horaCierre": "2019-10-19T20:00:00.363Z",
}
]
}
+--------------+
+ 2019-10-18 +
+--------------+
| First event |
| Secondevent |
+--------------+
+ 2018-10-19 +
+--------------+
| Second event |
+--------------+
+ x date |
+--------------+
| x event |
+--------------+
我想通过“horaApertura”来过滤它们,这样它们可以是这样的:
"clasesDB": [
{
"estado": true,
"_id": "5d9a90b21c9d440000c41909",
"horaApertura": "2019-10-18T13:00:00.363Z",
"horaCierre": "2019-10-18T14:00:00.363Z",
},
{
"estado": true,
"_id": "5d9adca55d091800171a7e27",
"horaApertura": "2019-10-18T18:00:00.363Z",
"horaCierre": "2019-10-18T19:00:00.363Z",
},
{
"estado": true,
"_id": "5d9adc9b5d091800171a7e26",
"horaApertura": "2019-10-19T19:00:00.363Z",
"horaCierre": "2019-10-19T20:00:00.363Z",
}
]
}
+--------------+
+ 2019-10-18 +
+--------------+
| First event |
| Secondevent |
+--------------+
+ 2018-10-19 +
+--------------+
| Second event |
+--------------+
+ x date |
+--------------+
| x event |
+--------------+
你们能帮我想一想我该怎么做吗?提前谢谢 您可以使用方法创建自定义管道以按日期分组 将此管道作为声明包含在模块中 并在模板中使用它,如下所示:
<div *ngFor="let item of classesDB | groupByDate">
<div>{{ item.date }}</div>
<div *ngFor="let event of item.events>{{ event }}</div>
</div>
可以使用方法创建自定义管道以按日期分组 将此管道作为声明包含在模块中 并在模板中使用它,如下所示:
<div *ngFor="let item of classesDB | groupByDate">
<div>{{ item.date }}</div>
<div *ngFor="let event of item.events>{{ event }}</div>
</div>
有什么不接受答案的原因吗?有什么不接受答案的原因吗?