Сначала преобразуйте ваши «data1», добавив свойство «date», которое было строкой даты в формате YYYYmmdd.Вы можете использовать эту функцию, чтобы добавить свойства: companyName и statusName, чтобы избежать вашего * ngIf.Я не доказываю, но это может быть похоже на
companies=[{id:999,name:"Airlink Communication"},{id:637,name:"Ascertia (Pvt) Ltd"},..]
const months=[{month:"00",name:"ENE"},{month:"01",name:"FEB"}...]
dataFormated=data.map(x=>{
const company=companies.find(c=>c.id==x.company_id);
const status=x.status.substring(0,1).toUpperCase()+x.status.substr(1)
const datepart=x.submitted_at.split('-');
const date=''+datepart[2]+month.find(m=>m.name==datepart[1]).month+datepart[0]
//date becomes, e.g. "180611" for x.submited_at "11-JUL-18"
return
{
...x,
companyName:company?company.name:'',
status:status
date:date
}
})
Ну, тогда вы можете фильтровать, используя новое свойство "date" - это строка, вы можете использовать фильтр или if-
Обновлено фильтр становится как
if (this.from && this.to) {
//first convert this.from and this.to to string of form YYmmdd
//your'e using simply html input type date that return a string
//I suggested you use mat-datepicker or ng-datepicker, but in your case
const fromDate = new Date(this.from.split(/\D/));
const toDate = new Date(this.to.split(/\D/));
//see how convert a number in string with 2 digits using slice(-2),
//e.g. ('0'+2).slice(-2) is "02"
const fromDateTxt=''+(fromDate.getFullYear()%100)+
('0'+fromDate.getMonth()+1).slice(-2)+
('0'+fromDate.getDate()).slice(-2)
const toDateTxt=''+(toDate.getFullYear()%100)+
('0'+toDate.getMonth()+1).slice(-2)+
('0'+toDate.getDate()).slice(-2)
this.data1=dataFormated.filter(
obj => obj.date >= fromDateTxt && obj.date< toDateTxt);
console.log(this.data1);
}