Untitled

mail@pastecode.io avatar
unknown
javascript
a year ago
1.2 kB
3
Indexable
Never
$scope.alterRange = function(){

            if (!$filter('isEmpty')($scope.dateRange.startDate)) {

                $scope.validDates.minEndDate = moment($scope.dateRange.startDate).startOf('day').toDate();




                if(moment($scope.dateRange.startDate).add(1, 'year').startOf('day').toDate() > $rootScope.currentDate) {

                    $scope.validDates.maxEndDate = $rootScope.currentDate;

                }

                else {

                    $scope.validDates.maxEndDate = moment($scope.dateRange.startDate).add(1, 'year').startOf('day').toDate();

                }                

            }

        };

        var refreshValidDates = function() {

            $scope.validDates.minDate = moment($rootScope.currentDate).subtract(5, 'years').startOf('day').toDate(),

            $scope.validDates.maxDate = moment($rootScope.currentDate).startOf('day').toDate(),

            $scope.validDates.minEndDate = moment($rootScope.currentDate).subtract(5, 'years').startOf('day').toDate(),

            $scope.validDates.maxEndDate = moment($rootScope.currentDate).startOf('day').toDate();




            $scope.alterRange();

        };

        refreshValidDates();