mirror of
https://github.com/HackPlan/angular-datepicker.git
synced 2026-06-10 15:18:45 +08:00
26 lines
622 B
JavaScript
26 lines
622 B
JavaScript
'use strict';
|
|
|
|
var Module = angular.module('datePicker');
|
|
|
|
Module.directive('dateRange', function () {
|
|
return {
|
|
templateUrl: 'templates/daterange.html',
|
|
scope: {
|
|
start: '=',
|
|
end: '='
|
|
},
|
|
link: function (scope) {
|
|
scope.$watch('start.getTime()', function (value) {
|
|
if (value && scope.end && value > scope.end.getTime()) {
|
|
scope.end = new Date(value);
|
|
}
|
|
});
|
|
scope.$watch('end.getTime()', function (value) {
|
|
if (value && scope.start && value < scope.start.getTime()) {
|
|
scope.start = new Date(value);
|
|
}
|
|
});
|
|
}
|
|
};
|
|
});
|