javascriptangularprimengangular-formlyngx-formly

Formly, primeng not able to set value of mindate(datepicker) in component using angular


I am using angular formly and primeng. I have FormlyFieldCalendar and AppComponent in place. Setting the property of minDate in and initialiting the value in FormlyFieldCalendar with minDate works fine, but when i am trying to set the minDate in AppComponent field its not working. Please find below both the scenarios, i have built the sample on StackBlitz for demonstration with link : https://stackblitz.com/edit/ngx-formly-ui-primeng-d7v5g4-nu6ctj?file=app/formly-field-primeng-calendar.ts

Scenario 1: (Works fine)

enter image description here

Scenario 2: (Not working)

I now tried removing the code of setting minDate in FormlyFieldCalendar instead trying to set in Appcomponent by 2 ways.

  1. By assigning in templateOptions.
  2. By using datePickerOptions provided in formly.dev webpage but seems doesnt work with primeng.

enter image description here


Solution

  • While assiging minDate in FormlyFieldCalendar Component we need to make sure we use alias to. It is an alias for field.templateOptions