refer:
http://stackoverflow.com/questions/10727207/angularjs-jquery-ui-binding-issue
http://jsfiddle.net/9BRNf/2/
<input id=”date2″ value=”1/1/1980″ ng-model=”toDate” my-datepicker />
angular.module(‘myApp.directives’, [])
.directive(‘myDatepicker’, function() {
return function(scope, element, attrs) {
element.datepicker({
changeYear : true,
changeMonth : true,
appendText : ‘(yyyy-mm-dd)’,
dateFormat : ‘yy-mm-dd’,
onSelect: function(dateText, inst) {
var mdlAttr = $(this).attr(‘ng-model’);
scope[attrs.ngModel] = dateText;
scope.$apply();
}
});
}
});