I'm new to Angular and to JS, therefore I'm sorry if my problem is quite trivial.
I'm using ui.bootstrap.datepicker to modify a date
property of my foo
model. My foo.date
is a string like '2000-01-31'
. What I want is to visualize foo.date
in the form as January 31, 2000
, while preserving 'foo.date' format to '2000-01-31'
.
Here there is my datepiker:
<div class="input-group">
<input type="text"
class="form-control"
datepicker-popup="MMMM dd, yyyy"
ng-model="foo.date"
is-open="opened"
ng-required="true"
show-weeks = 'false'
close-text="Close" />
<span class="input-group-btn">
<button type="button" class="btn btn-default" ng-click="pdfc.open($event)"><i class="glyphicon glyphicon-calendar"></i></button>
</span>
</div>
If I set datepicker-popup
to "MMMM dd, yyyy"
, the original date format of the model is broken. I see something like this:
"2000-01-31T00:00:00.000Z"
...instead of this:
2000-01-31
I read some related solutions like this one, but the directive.directive('datepickerPopup', function (){...}
is "overridden" by datepicker-popup
in the form.
In this plnkr you can see my problem in action. Is there a nice way to decouple those two date formats?