I have created a custom directive to add features to the existing matDatePicker control. This directive has an Input attribute called format which gives date format at run time. I have provided the MyDateAdapter as mention in Angular 2 Material 2 datepicker date format
My question is; how I can set the Input format value to the datepicker date format at run time as an when my value of format get changed.
My Directive:
@Directive({
selector: '[dateFormat]',
providers: [
{
provide: NG_VALIDATORS,
useExisting: DateFormatDirective,
multi: true
},
{
provide: DateAdapter, useClass: MyDateAdapter
},
{
provide: MAT_DATE_FORMATS, useValue: MY_DATE_FORMATS
}
]
})
export class DateFormatDirective {
@Input('dateFormat') format: string;
}
MyDateAdapter class and MY_DATE_FORMATS constant refer