按角度7按日期过滤表格?

问题描述 投票:-1回答:1

如何根据用户在角度7中选择的到期日期仅过滤表格中项目列表中的项目?

请考虑下表:

product: product1, product2, product3
exp-date: Mar 15 2019, Mar 16 2019, Mar 18 2019

来自API的回复:

[{"symbol":"AMD","optionType":"P","optionId":355395412,"strikePrice":28.0,"totalContracts":1.0,"expirationDate":"04/12/2019","premiumPerShare":40.4737,"parentId":null,"status":"Filled","manage":true},
{"symbol":"AMD","optionType":"C","optionId":355395018,"strikePrice":29.0,"totalContracts":1.0,"expirationDate":"04/12/2019","premiumPerShare":35.4237,"parentId":null,"status":"Filled","manage":true}]
angular angular7
1个回答
0
投票

假设您的selectedExpirationDate采用'mm / dd / yyyy'格式。 (如果不是你需要把它变成'mm / dd / yyyy')

var requriredProduct=this.products.filter(x=>x.expirationDate==selectedExpirationDate)
© www.soinside.com 2019 - 2024. All rights reserved.