我只想选择日期,但它也要求我选择时间。
我使用以下代码,
view.tpl.html
<div class='input-group date' id='datePicker'>
<input type='text' id="date" class="form-control"
ng-model="model.date" date-picker required />
<span class="input-group-addon">
<span class="glyphicon glyphicon-calendar"></span>
</span>
</div>
directive.js
angular.module('directives.date-picker', [])
.directive('datePicker',['$filter', '$window', function($filter, $window) {
return {
restrict: 'A',
scope: {
},
link: function(scope, element, attrs) {
var datePicker = document.getElementById('datePicker');
angular.element(datePicker).datetimepicker({
format: "yyyy-mm-dd",
showMeridian: true,
autoclose: true
});
angular.element($window).bind('keydown', function(event) {
if (event.keyCode === 27) {
angular.element(datePicker).datetimepicker('hide');
}
});
}
};
}]);
答案 0 :(得分:1)
将minView
属性添加到datetimepicker
对象,例如
minView
是datetimepicker应显示的最低视图。
angular.element(datePicker).datetimepicker({
format: "yyyy-mm-dd",
showMeridian: true,
autoclose: true,
minView : 1 //for day view minimum
});
Documentation此处如果这是您正在使用的datetimepicker
。
希望有所帮助