, (dateInput) (dateInput) , (keyup)
HTML
<mat-form-field>
<input #fromInput matInput [matDatepicker]="pickerFrom" placeholder="סנן תאריך התחלה"
(dateChange)="filterFrom($event)" (keyup)="filterInputKeyupFrom()">
<mat-datepicker-toggle matSuffix [for]="pickerFrom"></mat-datepicker-toggle>
<mat-datepicker #pickerFrom></mat-datepicker>
</mat-form-field>
TS
private parseInputDate(v):Date{
let a:Array<any> = v.split('.')
a.forEach((v, i) => a[i] = parseInt(v) + (i == 1 ? -1 : 0))
console.log(new Date(a[2], a[1], a[0]))
return new Date(a[2], a[1], a[0])
}
filterInputKeyupFrom(){
this.lastFrom = this.parseInputDate(this.fromInput.nativeElement.value)
if (this.lastFrom) {
this.lastFrom.setSeconds(-1)
}
this.filterDates()
}
filterInputKeyupUpTo(){
this.lastTo = this.parseInputDate(this.toInput.nativeElement.value)
if (this.lastTo) {
this.lastTo.setDate(this.lastTo.getDate()+1)
}
this.filterDates()
}
filterFrom(e:MatDatepickerInputEvent<Date>){
console.log('filterFrom')
if(e.value){
this.lastFrom = new Date(e.value)
if (this.lastFrom) {
this.lastFrom.setSeconds(-1)
}
this.filterDates()
}
}
filterUpTo(e:MatDatepickerInputEvent<Date>){
console.log('filterUpTo')
if(e.value){
this.lastTo = new Date(e.value)
if (this.lastTo) {
this.lastTo.setDate(this.lastTo.getDate()+1)
}
this.filterDates()
}
}