Issue
I want to access the formly datepicker to make it close after selecting the year. But Im not able to access the datepicer object. Can please anybody help? Thank you!
fieldsOfMyForm: FormlyFieldConfig[] = [
{
key: 'form',
type: 'repeat',
templateOptions: {
addText: 'my form',
},
fieldArray: { fieldGroup: [
{
key: 'myyear',
type: 'datepicker',
templateOptions: {
datepickerOptions: {
yearSelected: (( field: any, event: Moment) => {
// here is the part where I want to calls something like datepicker.close();
}
}
}
] }
Solution
yearSelected:
((field: FormlyFieldConfig, event: Moment, datepicker: MatDatepicker<Date>) => {
if (field.formControl) {
field.formControl.setValue(new Date(event.calendar()));
datepicker.close();
}
}
)
Answered By - Christoph Glaß
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.