के लिए बूटस्ट्रैप डेटपिकर निर्देश मैंने एक साधारण डेटपिकर निर्देश लिखा है।angularjs
appDirective.directive('datePicker', function() {
return {
restrict: 'E',
require: ['ngModel'],
scope: {
ngModel: '='
},
replace: true,
template:
'<div class="input-group">' +
'<input type="text" class="form-control" ngModel required>' +
'<span class="input-group-addon"><i class="glyphicon glyphicon-calendar"></i></span>' +
'</div>' ,
link: function(scope, element, attrs) {
var input = element.find('input');
var nowTemp = new Date();
var now = new Date(nowTemp.getFullYear(), nowTemp.getMonth(), nowTemp.getDate(),0,0,0,0);
console.log(now);
console.log(nowTemp);
input.datepicker({
format: "yyyy-mm-dd",
onRender: function(date) {
return date.valueOf() < now.valueOf() ? 'disabled' : '';
}
});
element.bind('blur keyup change', function() {
scope.ngModel = input.val();
console.info('date-picker event', input.val(), scope.ngModel);
});
}
}
});
इस datepicker चलाता है अगर मैं html
में <date-picker></date-picker>
का उपयोग: यहाँ कोड है।
हालांकि उपर्युक्त निर्देश में onRender
के लिए कॉलबैक काम नहीं करता है। मैं उसी उदाहरण का उपयोग कर रहा हूं जैसे Disable bootstrap dates
मैं यहां क्या गलत कर रहा हूं?
धन्यवाद :)