Reputation: 57
I'm trying to implement a mat datepicker in my project I have already tried almost all examples in angular material documentation
But always get this error:
core.js:6498 ERROR Error: Uncaught (in promise): TypeError: Cannot read properties of undefined (reading 'subscribe')
TypeError: Cannot read properties of undefined (reading 'subscribe')
at new MatDatepickerInputBase (datepicker.js:3041:1)
at new MatDatepickerInput (datepicker.js:3286:1)
at NodeInjectorFactory.MatDatepickerInput_Factory [as factory]
Any idea how to solve this?
I understand the why, because it is not receiving a promise, but how to fix this in the implementation?
I am not sure if it is an issue with the matdatepicker component or with the template variable used for the reference of the mat-datepicker, as when I delete [matDatepicker]="picker" (reference to #picker of , this error disapears, but the component does not achieve to be correctly built.
Thank you
Carlota
Upvotes: 0
Views: 2223
Reputation: 1454
Had the same issue today, and managed to fix it. The problem was related to the DateAdapter provider. Take a look at the MatDatepickerInputBase constructor, and you'll see it tries to subscribe to the DateAdapter language/locale change observable.
In my case I had registered a date adapter from a different library. Make sure to register a date adapter that inherits from the Material DateAdapter.
Upvotes: 1