Description :
angular.isDate
check whether the date is in proper date format or not, If the passed date is in string format, it return false as it is not in date format. In this example, it returns true because that is in proper date format.
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Welcome in the AngularJS</title> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.2/angular.min.js"></script> </head> <body ng-app="app"> <div ng-controller="isDateController"> isDate: {{isDate}} ({{date}}) </div> </body> </html> <script> var app = angular.module("app", []); app.controller('isDateController', ['$scope', function ($scope) { $scope.date = new Date; $scope.isDate = angular.isDate($scope.date) }]); </script>
Description :
In this example of angular.isDate
it will return false because date is in string format.
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Welcome in the AngularJS</title> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.2/angular.min.js"></script> </head> <body ng-app="app"> <div ng-controller="isDateController"> isDate: {{isDate}} ({{date}}) </div> </body> </html> <script> var app = angular.module("app", []); app.controller('isDateController', ['$scope', function ($scope) { $scope.date = (new Date).toLocaleDateString(); $scope.isDate = angular.isDate($scope.date) }]); </script>