angular - 如何根据日期属性过滤对象
问题描述
我有以下json:
[
{
"id": "58b1f024-f9dc-44d3-b07e-9672b5815563",
"userId": "0fdba3ec-90c2-41d7-9912-904f9d0b415d",
"appointment_date": "Tue Oct 20 2020",
"appointment_hour": "10:00 - 11:00",
"created_at": "2020-10-20T21:03:08.285Z",
"updated_at": "2020-10-20T21:03:08.285Z"
},
{
"id": "05591548-dbbe-49dc-a852-e887487bf2a6",
"userId": "ea97c2db-bdb3-4323-a070-91d751aa09b7",
"appointment_date": "Fri Oct 21 2020",
"appointment_hour": "14:00 - 15:00",
"created_at": "2020-10-20T22:08:16.307Z",
"updated_at": "2020-10-20T22:08:16.307Z"
},
{
"id": "5e57942d-33f6-40a8-aae7-bb84fd4c156e",
"userId": "ea97c2db-bdb3-4323-a070-91d751aa09b7",
"appointment_date": "Tue Oct 27 2020",
"appointment_hour": "20:00 - 21:00",
"created_at": "2020-10-20T22:08:17.745Z",
"updated_at": "2020-10-20T22:08:17.745Z"
},
{
"id": "dfc2a605-4e34-4110-8f91-64e618f7c846",
"userId": "0fdba3ec-90c2-41d7-9912-904f9d0b415d",
"appointment_date": "Tue Oct 27 2020",
"appointment_hour": "13:00 - 14:00",
"created_at": "2020-10-20T22:09:33.587Z",
"updated_at": "2020-10-20T22:09:33.587Z"
}
]
我需要在页面上显示这些数据,但要动态计算。例如,如果预约已通过(日期:2020 年 10 月 20 日星期二),那么我应该有一行带有 PASSED APPPOINTMENT HEADER 并且该行内的过滤对象带有已通过的日期
<div class="container">
<div class="row" *ngFor='let appointment of json'>
<h1>
Passed appointment
</h1>
<div>
{{ appointment.appointment_date}}
</div>
</div>
</div>
如果是今天的日期,那么其他行中的今天的对象。如果它的约会日期是例如下周(2020 年 10 月 27 日星期二:来自示例)或下个月,那么应该在下周或下个月的另一行中显示。这一切如何才能实现?
解决方案
推荐阅读
- c# - 添加迁移时出现构建错误
- algorithmic-trading - 使用 Binance API 在特定时间关闭/提交订单
- unit-testing - 可重用单元测试 C
- javascript - clearTimeout 运行,但未清除 setTimeout
- r - 使用 dplyr 根据 dplyr 中每组的其他列中的条件添加列,数据为长格式
- flutter - 将 OneSignal 从现有应用程序转移到 Flutter 应用程序
- html - 自动关闭的辅助功能加载对话框
- json - .fromJson 工厂的颤振通用函数
- python - 按具有错误阈值的数字列分组
- python - 连接两个多索引旋转数据框