The element of type Date allows the user to enter a date using a text box or date picker. Use the ng-model directive to store values from AngularJS application data into HTML input controls. Firefox does not currently support type="date". It converts all values into strings. Since
you want the date to be a real Date object and not a string, so we create another variable and then link these two variables as in the code given below
<input type = "date" ng-model = "realdate" /> function MainCtrl($scope, dateFilter) { $scope.date = new Date(); $scope.$watch('date', function (date){ $scope.dateString = dateFilter(date, 'yyyy-MM-dd'); }); $scope.$watch('realdate', function (realdate){ $scope.date = new Date(realdate); }); }
The above is the detailed content of AngularJS and HTML5 date input values - How to make Firefox display readable date values in date input?. For more information, please follow other related articles on the PHP Chinese website!