0

I have a date in $scope. When the page loads I want the input type="date" field value to be set on the value in $scope.

<input class="form-control" type="date"
        ng-model="asso.formation_of_association"
        placeholder="" />

But I only see dd-mm-yyy on the input field

2 Answers2

1

You should show your code becouse I prepared an example and it works.

<div ng-app>
  <div ng-controller="myCtrl">
    <input type="date" ng-model="date.formation_of_association">
  </div>
</div>

function myCtrl($scope) {

  $scope.asso = {
    'formation_of_association': '2018-06-21'
  };

}
webmazz
  • 79
  • 3
  • @boo [_"It is impossible to change the format"_](https://stackoverflow.com/questions/7372038/is-there-any-way-to-change-input-type-date-format). You can change the output instead, with a date filter. e.g. `

    {{asso.formation_of_association | date : 'dd-MM-yyyy'}}

    `
    – Aleksey Solovey Jun 21 '18 at 13:13
  • hey.. i think over 1.3v string won't be supported. that was my problem. i had date in string. @AlekseySolovey –  Jun 22 '18 at 05:18
0

check the type of the ng-model value with typeof

if the typeof returns a date replace in your input file with type date