var DemoApp = angular.module('DemoApp', ['dx']);
DemoApp.controller('DemoController', function DemoController($scope) {
$scope.workingDaysCount = 260;
$scope.behavior = {
callValueChanged: "onMoving"
};
$scope.rangeSelectorOptions = {
bindingOptions: {
behavior: "behavior"
},
margin: {
top: 50
},
scale: {
startValue: new Date(2011, 0, 1),
endValue: new Date(2011, 11, 31),
minorTickInterval: "day",
tickInterval: "month",
minorTick: {
visible: false,
},
marker: { visible: false },
label: {
format: "MMM"
}
},
sliderMarker: {
format: "dd EEEE"
},
title: "Calculate the Working Days Count in a Date Period",
onValueChanged: function (e) {
var currentDate = new Date(e.value[0]),
workingDaysCount = 0;
while (currentDate <= e.value[1]) {
if(currentDate.getDay() > 0 && currentDate.getDay() < 6) {
workingDaysCount++;
}
currentDate.setDate(currentDate.getDate() + 1);
}
$scope.workingDaysCount = workingDaysCount.toFixed();
}
};
$scope.selectBoxOptions = {
bindingOptions: {
value: "behavior.callValueChanged"
},
dataSource: ["onMoving", "onMovingComplete"],
width: 210
};
});
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>DevExtreme Demo</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script>window.jQuery || document.write(decodeURIComponent('%3Cscript src="js/jquery.min.js"%3E%3C/script%3E'))</script>
<link rel="stylesheet" type="text/css" href="https://cdn3.devexpress.com/jslib/20.2.4/css/dx.common.css" />
<link rel="stylesheet" type="text/css" href="https://cdn3.devexpress.com/jslib/20.2.4/css/dx.light.css" />
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.16/angular.min.js"></script>
<script>window.angular || document.write(decodeURIComponent('%3Cscript src="js/angular.min.js"%3E%3C/script%3E'))</script>
<script src="https://cdn3.devexpress.com/jslib/20.2.4/js/dx.all.js"></script>
<link rel="stylesheet" type="text/css" href="styles.css" />
<script src="index.js"></script>
</head>
<body class="dx-viewport">
<div class="demo-container" ng-app="DemoApp" ng-controller="DemoController">
<div id="range-selector-demo">
<div id="range-selector" dx-range-selector="rangeSelectorOptions"></div>
<h2>Working days count: <span>{{workingDaysCount}}</span></h2>
<div class="options">
<div class="caption">Options</div>
<div class="option">
<span>Handle Range Changes</span>
<div id="handle" dx-select-box="selectBoxOptions"></div>
</div>
</div>
</div>
</div>
</body>
</html>
#range-selector {
height: 200px;
}
h2 {
text-align: center;
}
.options {
padding: 20px;
background-color: rgba(191, 191, 191, 0.15);
position: absolute;
bottom: 0;
left: 0;
right: 0;
}
.option {
margin-top: 10px;
}
.caption {
font-size: 18px;
font-weight: 500;
}
.option > span {
margin-right: 10px;
}
.option > .dx-widget {
display: inline-block;
vertical-align: middle;
}