omer bach omer bach - 5 months ago 24
AngularJS Question

angular bootstrap datepicker mismatch between view and model

I'm using angular bootstrap timepicker.
The problem I'm facing is that I have a mismatch between the view and the model.
As you can see from the example, I chose 2015-05-07 but the model is a day behind.

<div dir="ltr" class="col-md-3 datePickerComponent">
<div>{{payments.user.start_dt}}</div>
<span dir="rtl" class="datePickerLabel">
תאריך התחלה
</span>&nbsp;
<p class="input-group">
<input ng-disabled="true" dir="rtl" ng-change="payments.GetPayments()" type="text" class="form-control" datepicker-popup="dd-MM-yyyy" ng-model="payments.user.start_dt" is-open="payments.opened_start" />
<span class="input-group-btn">
<button type="button" class="btn btn-default" ng-click="payments.open_start($event)"><i class="glyphicon glyphicon-calendar"></i></button>
</span>
</p>
</div>


enter image description here

Answer

Apply the date filter to the value in your view

<div>{{payments.user.start_dt | date : format : timezone}}</div>

e.g.

<div>{{payments.user.start_dt | date : longDate}}</div>

see AngularJS Docs - Date Filter

Comments