functionM"/> functionM">

Home >Web Front-end >HTML Tutorial >AngularJS and HTML5 date input values ​​- How to make Firefox display readable date values ​​in date input?

AngularJS and HTML5 date input values ​​- How to make Firefox display readable date values ​​in date input?

王林
王林forward
2023-09-10 11:53:02985browse

AngularJS和HTML5日期输入值 - 如何让Firefox在日期输入中显示可读的日期值?

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(&#39;date&#39;, function (date){
      $scope.dateString = dateFilter(date, &#39;yyyy-MM-dd&#39;);
   });
   $scope.$watch(&#39;realdate&#39;, 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!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete