Files
angular-datepicker/app/scripts/dateRange.js
2013-10-13 23:50:29 +02:00

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);
}
});
}
};
});