The best way to implement a datepicker on website, in my opinion, is through
HTML5 input tag with type=date. This input type, however, is not
well-supported. AngularJS is a very promising extension for HTML, so I did
some study on how to implement datepicker with AngularJS. The easiest way is to
combine AngularJS directive and jQuery datepicker. The following is demo and
complete source code:
<!doctype html><htmlng-app="demo"><head><metacharset="utf-8"><title>datepicker with AngularJS and jQuery</title><linkrel="stylesheet"href="https://code.jquery.com/ui/1.11.3/themes/smoothness/jquery-ui.css"></head><bodyng-controller="myCtrl"><inputtype="text"ng-model="date"datepicker/>{{date}}<scriptsrc="https://code.jquery.com/jquery-1.10.2.min.js"></script><scriptsrc="https://code.jquery.com/ui/1.11.3/jquery-ui.min.js"></script><scriptsrc="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.11/angular.min.js"></script><scriptsrc="directive.js"></script><!-- tested on AngularJS 1.3.11 and 1.0.4 --></script></body></html>
// tested on AngularJS 1.3.11 and 1.0.4angular.module('demo',[]).directive('datepicker',['$parse',function($parse){vardirectiveDefinitionObject={restrict:'A',link:functionpostLink(scope,iElement,iAttrs){iElement.datepicker({dateFormat:'yy-mm-dd',onSelect:function(dateText,inst){scope.$apply(function(scope){$parse(iAttrs.ngModel).assign(scope,dateText);});}});}};returndirectiveDefinitionObject;}]).controller('myCtrl',['$scope',function($scope){$scope.date="1212-12-12";}]);