omer bach omer bach -5 years ago 178
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">
<span dir="rtl" class="datePickerLabel">
תאריך התחלה
<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>

enter image description here

Answer Source

Apply the date filter to the value in your view

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


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

see AngularJS Docs - Date Filter

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download