add support to disable the date picker

This commit is contained in:
Costica Puntaru
2014-06-13 16:54:30 +03:00
parent c6850b641e
commit 832bf1feab
3 changed files with 8 additions and 2 deletions

View File

@@ -185,6 +185,9 @@ Module.directive('datePicker', ['datePickerConfig', function datePickerDirective
};
scope.setDate = function (date) {
if(attrs.disabled) {
return
}
scope.date = date;
// change next view
var nextView = scope.views[scope.views.indexOf(scope.view) + 1];

View File

@@ -10,6 +10,9 @@ Module.directive('dateRange', function () {
end: '='
},
link: function (scope) {
attrs.$observe('disabled', function(isDisabled){
scope.disableDatePickers = isDisabled
});
scope.$watch('start.getTime()', function (value) {
if (value && scope.end && value > scope.end.getTime()) {
scope.end = new Date(value);

View File

@@ -2,10 +2,10 @@
<table>
<tr>
<td valign="top">
<div date-picker="start" class="date-picker" date after="start" before="end" min-view="date" max-view="date"></div>
<div date-picker="start" ng-disabled="disableDatePickers" class="date-picker" date after="start" before="end" min-view="date" max-view="date"></div>
</td>
<td valign="top">
<div date-picker="end" class="date-picker" date after="start" before="end" min-view="date" max-view="date"></div>
<div date-picker="end" ng-disabled="disableDatePickers" class="date-picker" date after="start" before="end" min-view="date" max-view="date"></div>
</td>
</tr>
</table>