0

I am using reactive forms, in this if i click on date from the bootstrap calendar, the value is coming as empty, but if i change the selected date from the formControl input, then that value has been taken. I am not getting where i am going wrong.

DEMO

HTML:

<div class="form-group">
                <label for="">Premium Commitment Date</label>
                <input type="text" class="form-control" placeholder="MM/DD/YYYY" formControlName="premiumCommDate"
                  name="premiumCommDate"></div>

Ts:

 $('.onlyDate').datetimepicker({
        format: 'L'
      });

this.agentbasicInfoForm = this.FB.group({
        premiumCommDate: [''],
})
Bhrungarajni
  • 2,415
  • 11
  • 44
  • 88

1 Answers1

1

Since using Jquery, you have to listen datepickerchange event to get datepicker value, then set the reactive form value manullay using setValue or patchValue.

Try this:

date(event,i) {
   $('.onlyDateTime').datetimepicker();
      $('.onlyDate').datetimepicker({
        format: 'L'
      });
   $('.onlyDate').datetimepicker(
    { format: 'L' }).on('dp.change', (e)=>{
      const date = e.date.format('L');
      this.getFormData.at(i).get('signatureDate').setValue(date,{emitEvent:false});
      });
  }

Example

Chellappan வ
  • 23,645
  • 3
  • 29
  • 60