Angular Material DatePicker - Error: MdDatepicker: No provider found for DateAdapter
The example in the docs actually does import MdNativeDateModule
. Click on the plunker link and see the main.ts file. The docs are not as clear about this as would be preferred.
MdDatepickerModule
is the module containing the component itself. The component is agnostic to which implementation of dates you use with it.
For example, if you wished to use Moment.JS dates instead of JavaScript's native Date
objects, you could write your own class to work with Moment.JS objects. This is explained here.
If you simply want to work with JavaScript's Date
objects, though, you would need to use the NativeDateAdapter
class that is already included in @angular/material
. This class is provided by the MdNativeDateModule
.
It is not provided by MdDatepickerModule
since that module deals only with the UI component, and in case you were using Moment.JS objects, you would have no need for the NativeDateAdapter
class in your application.
you need to import MatNativeDateModule
from @angular/material
once you imported, you should have to import and export it in @NgModule
you can see on angular material