Untitled

Anonymous
javascript
07/03/2023 7:43 PM
1.6 KB
22
Indexable
$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();
Editor is loading...