【发布时间】:2016-03-07 08:49:26
【问题描述】:
我一直在使用 Ui angular bootstrap datepicker,它运行良好......在 chrome 中。
事实证明,Firefox 和 safari 不会显示日期选择器。以前任何人都遇到过这种情况。
我的 HTML 看起来像这样
<p class="input-group">
<input type="date" class="form-control" datepicker-popup ng-model="startDate" is-open="status.opened" min-date="minDate" max-date="maxDate" datepicker-options="dateOptions" date-disabled="disabled(date, mode)" close-text="Close" />
</p>
我的 JS/Controller 看起来像这样
$scope.today = function () {
$scope.startDate = new Date();
$scope.startDate.setMonth($scope.startDate.getMonth() - 1);
$scope.endDate = new Date();
$scope.endDate.setMonth($scope.endDate.getMonth() + 1);
};
$scope.today();
$scope.clear = function () {
$scope.dt = null;
};
// Disable weekend selection
$scope.disabled = function (date, mode) {
return (mode === 'day' && (date.getDay() === 0 || date.getDay() === 6));
};
$scope.open = function ($event) {
$scope.status.opened = true;
};
$scope.setDate = function (year, month, day) {
$scope.startDate = new Date(year, month, day);
$scope.endDate = new Date(year, month, day);
};
$scope.dateOptions = {
formatYear: 'yy',
};
$scope.formats = ['dd-MMMM-yyyy', 'yyyy/MM/dd', 'dd.MM.yyyy', 'shortDate'];
$scope.format = $scope.formats[0];
$scope.status = {
opened: false
};
如前所述,这行得通。但在 Firefox 和 safari 中,它没有显示日期选择器,但它在 chrome 中显示。
【问题讨论】:
标签: javascript angularjs angular-ui-bootstrap bootstrap-datepicker