main.html
<ul class="dropdown-menu" role="menu" aria-labelledby="dLabel">
<datetimepicker data-ng-model="dateRangeStart" data-datetimepicker-config="{ dropdownSelector: '#dropdownStart', renderOn: 'end-date-changed' }" data-on-set-time="startDateOnSetTime()" data-before-render="startDateBeforeRender($dates)"></datetimepicker>
</ul>
我正在使用角度指令https://github.com/dalelotts/angular-bootstrap-datetimepicker,如果您在此模块中选择日期和时间,它将显示
Thu Mar 23 2017 15:46:38 GMT-0400 (Eastern Daylight Time)
,所以这里有可能摆脱46:38 GMT-0400 (Eastern Daylight Time)
这部分,我只想选择小时?Ctrl.js
$scope.dateRangeStart = new Date();
$scope.dateRangeStart.setDate($scope.dateRangeStart.getDate() - 1);
$scope.dateRangeEnd = new Date();
$scope.endDateBeforeRender = endDateBeforeRender
$scope.endDateOnSetTime = endDateOnSetTime
$scope.startDateBeforeRender = startDateBeforeRender
$scope.startDateOnSetTime = startDateOnSetTime
function startDateOnSetTime () {
$scope.$broadcast('start-date-changed');
}
function endDateOnSetTime () {
$scope.$broadcast('end-date-changed');
}
function startDateBeforeRender ($dates) {
if ($scope.dateRangeEnd) {
var activeDate = moment($scope.dateRangeEnd);
$dates.filter(function (date) {
$scope.searchObj.endDate = activeDate._i;
// console.log(activeDate);
return date.localDateValue() >= activeDate.valueOf()
}).forEach(function (date) {
date.selectable = false;
// console.log(date);
})
}
}
最佳答案
您需要根据文档在配置中设置minView选项。这是日期选择器应显示的最小时间面额。将其设置为小时或几天,但是您可以根据需要设置。
上面的例子:
data-datetimepicker-config="{ dropdownSelector: '#dropdownStart', renderOn: 'end-date-changed', minView: 'hour' }"
关于javascript - 如何禁用 Angular 日期选择器中的分钟和文本(东部标准时间)?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/43008103/