如何根据用户在角度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}]
假设您的selectedExpirationDate采用'mm / dd / yyyy'格式。 (如果不是你需要把它变成'mm / dd / yyyy')
var requriredProduct=this.products.filter(x=>x.expirationDate==selectedExpirationDate)