0
I need to make a filter composed by the status and dateInicio of an object.
The section below is just an abstraction of what came to mind, would be correct or is there a better way to implement?
Array:any = [
{"titulo" = "test1", "dataInicio" = "12/02/2019", "status" = "aguardando"},
{"titulo" = "test2", "dataInicio" = "13/02/2019", "status" = "iniciada"},
{"titulo" = "test3", "dataInicio" = "14/02/2019", "status" = "finalizada"}
];
filtroStatus: string = null; //aguardando, iniciada, finalizada
filtroData: Date = new Date();
getFiltro(){
let statusArray = this.Array.filter(d =>d.status === this.filtroStatus);
let retornoArray = [];
for(var element in statusArray){
let dt = new Date.(element.dataInicio);
if(dt === filtroData){
retornoArray.push(element);
}
Return retornoArray
}
}
This way you can already filter by status and date at a single time.
– Lucas Brogni