Input type date ng-model

i have affect curent day to the input date to be the default valut.
how can i affect this value to ng-model??
how an i use input type date with ng-model without getting this error in send. ```
Error: [ngModel:datefmt]

Please share what you have so far.

what i'am trying to do is set default value of input date to current day and bind this value to ng-model.

 <input type="date" ng-model="msg.payload.dateselected" id="date" name="Date" ><br>
 <input type="text" ng-model="msg.machine" id="machine" name="Machine" placeholder="Machine" ng-virtual-keyboard/><br>
  <button id="myBtn" ng-click="output(msg)" ng-disabled="(msg.machine == null)" >save</button>

 (function($scope) {
 var date = new Date();
  var local = new Date(date);
  local.setMinutes(date.getMinutes() - date.getTimezoneOffset());
  document.getElementById("date").value = local.toJSON().slice(0, 10);
      $scope.msg.payload.dateselected =  $('#date').val();

(function($scope) {
     $scope.msg = {"machine":""}

     $scope.output = function(msg){

         $scope.msg.machine = $('#machine').val()

            $scope.msg.payload = ""

It was harder than I thought, but here's what I came up with:

<input type="date" ng-init="date = StrToDate(msg.payload)" ng-model="date" ng-change="msg.payload = date.toLocaleDateString(); send(msg)">

 (function($scope) {
    $scope.msg = {}
    $scope.msg.payload = new Date()
    $scope.StrToDate = function (str) {
        return new Date(str);
1 Like