0

i've a strange behaviour with a model.

$scope.ev = temp;

<input type="text" class="form-control" id="inputDataFineEv" ng-model="ev.dataOraFineEvento" placeholder="Data fine" value="{{ev.dataOraFineEvento | date:'dd/MM/yyyy'}}">

The result in html source is:

<input type="text" class="form-control ng-pristine ng-untouched ng-valid" id="inputDataFineEv" ng-model="ev.dataOraFineEvento" placeholder="Data fine" value="12/09/2015">

and on screen i see timestamp

screenshot

What am I doing wrong?

Thanks

amagtra
  • 45
  • 4

1 Answers1

0

First of all you can't use the value attribute with an ng-model because it's ng-model to do the bind, so you should filter the date from the controller to directly bind it filtered:

HTML:

<input type="text" class="form-control" id="inputDataFineEv" ng-model="ev.dataOraFineEvento" placeholder="Data fine">

JS:

angular.module('myApp', ['ngSanitize'])
    .controller('dummy', ['$scope', '$filter', function ($scope, $filter) {

    $scope.ev = {
        dataOraFineEvento: $filter('date')((1441113680*1000), 'mm/dd/yyyy')
    };

}]);

JSFiddle

michelem
  • 14,430
  • 5
  • 50
  • 66