Can't bind to 'matDatepicker' since it isn't a known property of 'input' - Angular

后端 未结 5 1761
死守一世寂寞
死守一世寂寞 2020-12-29 18:08

I have just copied and pasted angular material code for datePicker and input, but I am getting this error for the datePicker.

app.module



        
5条回答
  •  庸人自扰
    2020-12-29 19:03

    you need to import FormsModule and ReactiveFormsModule if you used NgModule and formgroup. so your app.module should be like that

    import {MaterialModule} from '@angular/material';
    @NgModule({
      imports: [
        MdDatepickerModule,        
        MdNativeDateModule,
        FormsModule,
        ReactiveFormsModule
      ]
    

    Note: MaterialModule Removed. please use separate module instead. like MdDatepickerModule see here https://github.com/angular/material2/blob/master/CHANGELOG.md#200-beta11-carapace-parapet-2017-09-21

提交回复
热议问题