如何基于用户在角度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}]
答案 0 :(得分:0)
假设您的selectedExpirationDate为'mm / dd / yyyy'格式。 (如果不是,则需要将其转换为“ mm / dd / yyyy”)
var requriredProduct=this.products.filter(x=>x.expirationDate==selectedExpirationDate)