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

王林
Release: 2023-09-10 11:53:02
forward
958 people have browsed it

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);
   });
}
Copy after login

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!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template