我正在使用AngularJs和AngularMaterials,我希望我的应用程序中的用户将日期输入定义为以下格式(2016-01-01T00:00:00)的范围。如何修改AngularJS滑块以用于日期输入?
答案 0 :(得分:1)
我在jsfiddle
上添加了一个示例<强> HTML 强>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.3/angular.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular-ui-bootstrap/0.14.3/ui-bootstrap-tpls.js"></script>
<script src="https://rawgit.com/rzajac/angularjs-slider/master/dist/rzslider.js"></script>
<div ng-app="rzSliderDemo">
<div ng-controller="MainCtrl" class="wrapper">
<article>
<rzslider rz-slider-model="slider.minValue"
rz-slider-high="slider.maxValue"
rz-slider-options="slider.options"></rzslider>
</article>
</div>
</div>
<强> JAVASCRIPT 强>
var app = angular.module('rzSliderDemo', ['rzModule', 'ui.bootstrap']);
app.controller('MainCtrl', function ($scope, $rootScope, $timeout, $modal) {
var date1 = new Date(2017, 3, 1);
var date2 = new Date();
var day;
var dateArray = [date1];
while(date1 <= date2) {
day = date1.getDate()
date1 = new Date(date1.setDate(++day));
dateArray.push(date1);
}
$scope.slider = {
minValue: dateArray[0],
maxValue: dateArray[dateArray.length-1],
value: dateArray[0], // or new Date(2016, 7, 10) is you want to use different instances
options: {
stepsArray: dateArray,
translate: function(date) {
if (date != null)
return date.toISOString();
return '';
}
}
};
});