I'm using a normal Angular Material Datepicker (Angular 13), but I added some action buttons:
See my example: https://stackblitz.com/edit/angular-material-13-starter-x1xj4z-wzqxfv?file=src%2Fapp%2Fapp.component.html
The clear button and 'infinity' button work fine. Once clicked, the date is cleared or set and the popup closes. Perfect!
However, selecting a date works only by selecting the date and pressing the ok button.
What I want: Selecting the date closes immediately the popup while setting the date. Just like the behaviour there exists without mat-datepicker-actions.
Any one knows how I can achieve this?
This shouldn't be the answer, but it works:
@ViewChild(MatDatepicker) picker: MatDatepicker<any>;
ngAfterViewInit() {
this.picker.openedStream.subscribe((event) => {
setTimeout(() => {
this.picker['_componentRef'].instance._calendar._userSelection.subscribe((event) => {
console.log('Element selected')
})
},0)
});
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With