I got a input field type date. There is date picker by AngularJS. When user comes to edit already saved form, AngularJS is throwing an error and date is not set at all, it is empty in UI. I really appreciate for your help!
HTML
<div class="col-md-10">
<input type="date" name="purchaseDate" class="form-control" ng-model="rma.purchaseDate" placeholder="{{translation.DATEOFPERMIT_PLACEHOLDER}}">
</div>
Controller
//In mySQL DB format is: 2015-07-02
$scope.rma.purchaseDate = $filter("date")(new Date(rma.purchaseDate).toISOString(), 'dd-MM-yyyy');
console.log($scope.rma.purchaseDate);
in console.log
Error: [ngModel:datefmt] Expected
02-07-2015
to be a dateThe specified value '02-07-2015' does not conform to the required format, 'yyyy-MM-dd'.
In UI
In the UI the format is dd/mm/yyyy
UPDATE
I just took filter off and tried very simple way and this is working:
$scope.rma.purchaseDate = new Date(rma.purchaseDate);
Thanks all!