Angular Material Datepicker will not work for me

Viewed 5461

Im trying to use the date picker. I have no issue with the checkbox or radio buttons. But when I try and add the date picker I always get this error:

Error: Template parse errors: Can't bind to 'htmlFor' since it isn't a known property of 'md-datepicker-toggle'

in my app.module.ts file:

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { MdButtonModule, 
    MdCheckboxModule,
    MdCardModule,
    MdRadioModule, 
    MdDatepickerModule } from '@angular/material';

import { AppComponent } from './app.component';
import { WeekControlComponent } from './week-control.component';

@NgModule({
declarations: [
  AppComponent,
  WeekControlComponent
],
imports: [
   BrowserModule, 
   FormsModule,
   MdButtonModule, 
   MdCheckboxModule, 
   MdCardModule, 
   MdRadioModule,
   MdDatepickerModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }

And I have a WeekControlComponent:

HTML
<input mdInput [mdDatepicker]="picker" placeholder="Choose a date">
<md-datepicker-toggle mdSuffix [for]="picker"></md-datepicker-toggle>
<md-datepicker #picker></md-datepicker>
TS
  import { Component, OnInit } from '@angular/core';

  @Component({
    selector: 'app-week-control',
    templateUrl: './week-control.component.html',
    styleUrls: ['./week-control.component.css']
  })
  export class WeekControlComponent implements OnInit {

    constructor() { }

    ngOnInit() {
    }
  }

I copied the example straight from the angular.io material examples page. I dont understand why its not working. Can someone please help me here?

2 Answers
Related