import { Component } from '@angular/core' ; import { FormControl } from '@angular/forms' ; import { MAT_MOMENT_DATE_FORMATS , MomentDateAdapter } from '@angular/material-moment-adapter' ; import { DateAdapter , MAT_DATE_FORMATS , MAT_DATE_LOCALE } from '@angular/material/core' ; import * as _moment from 'moment' ; import { default as _rollupMoment } from 'moment' ; const moment = _rollupMoment || _moment ; title @ Component ( { selector : 'datepicker-moment-example' , templateUrl : 'datepicker-moment-example.html' , styleUrls : [ 'datepicker-moment-example.css' ] , providers : [ { provide : DateAdapter , useClass : MomentDateAdapter , deps : [ MAT_DATE_LOCALE ] } , { provide : MAT_DATE_FORMATS , useValue : MAT_MOMENT_DATE_FORMATS } , ] , } ) export class DatepickerMomentExample { date = new FormControl ( moment ( [ 2017 , 0 , 1 ] ) ) ; }