5

Hello Currently I am using ng-2 datepicker 1.8.3 version in angular 2

<ng2-datepicker  [options]="InvoicedDateOption" formControlName="invoiceDate"  [(ngModel)]="InvoiceDatepickerValue"  ></ng2-datepicker>

when I initially bind datepicker with datepicker option it works and binds ngModel values but when a form is submitted it ngModel values are gone.

options that I used to bind.

this.InvoicedDateOption = new DatePickerOptions({ autoApply: true, initialDate: new Date(), format: "MM-DD-YYYY" });

initially HTML look like below

enter image description here

But after a form is submitted that ng-reflect-model is gone and value of ngModel is not updated. see below image.enter image description here

I don't know after form submit when I again apply the same option to ng2-datepicker it is not bound to ngModel.

I searched many options but nothing is work. but it is still not working.

Please help!

Community
  • 1
  • 1
Shah Niral
  • 121
  • 11
  • can you please add stackblitz example? – Yerkon Mar 20 '18 at 10:35
  • https://www.npmjs.com/package/angular4-datepicker - have you tried `dateFormat` instead of `format`. Never used this component - but this looks like it may be the solution. – JGFMK Feb 15 '19 at 12:23

0 Answers0