I have JQuery UI's datepicker working in my angular 2 application, however it is not updating my ngModel. I have a variable called SeasonStartDate, which I want to update to whatever date the user inputs. When I select a date in my date picker, so October 31st for example, my input will fill with 10/31/2016, as I would expect, but ngModel isn't successfully updating.
Here is my input:
<input [ngModel]="SeasonStartDate" (ngModelChange)="updateSeasonStartDate($event)" class="form-control date-picker" id="SeasonStartDate" name="SeasonStartDate" type="text" autocomplete="off">
Date: {{SeasonStartDate}}
I added Date: {{SeasonStartDate}} below the input so I can test whether or not the value is updating.
Here is the code in my component that updates the value:
updateSeasonStartDate(updateSeasonStartDate: any) {
console.log(updateSeasonStartDate);
this.SeasonStartDate = updateSeasonStartDate;
}
If I remove the date-picker class (which is needed to initiate the date picker) and I just manually type in the input, SeasonStartDate will update as expected, so I know the rest of my code works, it's just the date picker that ends up breaking it. How can I get ngModel and JQuery UI Datepicker to work together? Is this possible? I know there are other date pickers out there specifically for Angular 2, but I prefer JQuery's version if possible.