- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
AngularJS and HTML5 date input value - how to get Firefox to show a readable date value in a date input?
The <input> elements of type date allows user to enter date, using a text box or using date picker. With the ng-model directive, bins the values of AngularJS application data to HTML input controls. Firefox does not currently support type="date". It will convert all the values to string. Since
you want date to be a real Date object and not a string, so we create another variable, and then link the two variables as done in the below given code
<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); }); }
Advertisements