Reputation: 229
I use bootstrap datepicker and have following issue:
<input type="text" class="form-control" ng-click="viewModel.toggleDatepicker()" ng-model="viewModel.selectedDate" min-date="viewModel.datepicker.minDate" max-date="viewModel.datepicker.maxDate" datepicker-options="viewModel.datepicker.options"show-button-bar="false" />
and in Controller:
var today = this.selectedDate;
var nextWeek = this.selectedDate;
nextWeek.setDate(nextWeek.getDate() + this.DaysSlots);
after those lines gets executed both today and nextWeek points to the same date. Why is that?
Thanks for response
Upvotes: 0
Views: 135
Reputation: 23
To make your overall experince with angular dates better, you should look into moment .js
It allows you to create, format, add and subtract dates easily and with minimal issues. Using the default date.setDate function can cause lots of issues
Upvotes: 1