Including datepicker in Angular
Directive code
angular.module('appName').directive('myDatepicker', function ($parse) {
return function (scope, element, attrs, controller) {
var ngModel = $parse(attrs.ngModel);
$(function () {
element.datepicker({
dateFormat: 'yy-mm-dd',
onSelect: function (dateText, inst) {
scope.$apply(function (scope) {
// Change binded variable
ngModel.assign(scope, dateText);
});
}
});
});
}
});
html code
<input class="form-control" my-datepicker="" name="reqdate" placeholder="Requested Date" required="" type="text" />
http://jqueryui.com/
No comments:
Post a Comment