/*I am looking to define the maxDate as vmEndDate*/
app.directive('myDatepicker', function ($parse) {
return function (scope, element, attrs, controller) {
var ngModel = $parse(attrs.ngModel);
alert(element.val());
$(function(){
element.datepicker({
showOn:"both",
// changeYear:true,
//changeMonth:true,
dateFormat:'dd-MMMM-yyyy',
//maxDate: vmEndDate,
minDate: new Date(),
// yearRange: '1920:2012',
onSelect:function (dateText, inst) {
scope.$apply(function(scope){
// Change binded variable
ngModel.assign(scope, dateText);
});
}
});
});
}
});
/*html code */
<input id="dp" type="text" ng-model="vmEndDate" name="mDate" my-datepicker/>
/Aim: I aim to create a customized date picker with minimum and maximum dates, where the minimum date is today and the maximum date is fetched from the server (vmEndDate)/