Date in ng-Model with input date presents error in AngularJs

1

Good night, I'm trying to get the CRUD in my application, using AngularJS and WEBService , when I'm going to change data for a particular driver, I send JSON of it to% %, on the change page, access the object, as well as its attributes through SessionStorage of the inputs.

When not dealing with dates, ng-model is populated with input data, however, when dealing with dates, SessionStorage has the following error in the console:

  

Error: [ngModel: datefmt].

Would anyone know how to solve this error? I could not find answers until then. Thank you in advance!

My input:

<label> Data de validade </label>
<input type="date" ng-model="motorista.data_vencimento" id="codigo_motorista" />

My method that sends the object in format AngularJS to JSON :

$scope.enviarDados = function(motorista){
    $scope.jsonObj = angular.toJson(motorista, false);
    window.sessionStorage.motorista = JSON.stringify(motorista);
    window.location.href = "formAlterarMotorista.jsp";
}
    
asked by anonymous 01.03.2017 / 00:59

1 answer

1

The date format you need to pass in order for input to recognize how a valid date format should be:

YYYY-MM-DD //ano-mes-dia

Therefore, you should format the date before assigning it to the field.

    
01.03.2017 / 01:20