4

After import MdDatepickerModule and MdNativeDateModule, in my html:

<input mdInput [mdDatepicker]="startPicker" placeholder="Choose a date">
<md-datepicker-toggle mdSuffix [for]="startPicker"></md-datepicker-toggle>
<md-datepicker #startPicker></md-datepicker>

And it has error that: oc-datepicker-toggle is not a known element.

FAISAL
  • 33,618
  • 10
  • 97
  • 105
gavinSong
  • 215
  • 2
  • 12

1 Answers1

4

<md-datepicker-toggle> was introduced in Material 2.0.0-beta.10. See this CHANGELOG for more details.

mdDatepickerToggle is now an element < md-datepicker-toggle > with a for property that points to the MdDatepicker instance.

If you are using an earlier version of Material 2, then using <md-datepicker-toggle> will throw this error. To update to the new version, do the following:

  • In your package.json, change "@angular/material" and "@angular/cdk" version to "2.0.0-beta.10"
  • In your terminal window, navigate to the folder in your project where package.json is located.
  • Run the command npm install

Here is a working demo using version 2.0.0-beta.10.

FAISAL
  • 33,618
  • 10
  • 97
  • 105