angularjs ui日期仅显示月份和年份
我正在使用ui-date指令() 默认情况下,此UI日历组件正在获取日期。我只能得到没有日期的月份和年份angularjs ui日期仅显示月份和年份,angularjs,angularjs-directive,Angularjs,Angularjs Directive,我正在使用ui-date指令() 默认情况下,此UI日历组件正在获取日期。我只能得到没有日期的月份和年份 如何只获取月份和年份?我不知道ui日期指令,但我的需求与您完全相同 您可以使用bootstrap datepicker并查找符合您需要的min view mode参数。以下代码适合我。谢谢 $scope.expireDate = { dateFormat: 'mm-yy', changeMonth: true, changeYear: true, showBu
如何只获取月份和年份?我不知道ui日期指令,但我的需求与您完全相同
您可以使用bootstrap datepicker并查找符合您需要的min view mode参数。以下代码适合我。谢谢
$scope.expireDate = {
dateFormat: 'mm-yy',
changeMonth: true,
changeYear: true,
showButtonPanel: true,
onClose: function() {
function isDonePressed() {
return ($('#ui-datepicker-div').html().indexOf('ui-datepicker-close ui-state-default ui-priority-primary ui-corner-all ui-state-hover') > -1);
}
if (isDonePressed()) {
var month = $("#ui-datepicker-div .ui-datepicker-month :selected").val();
var year = $("#ui-datepicker-div .ui-datepicker-year :selected").val();
$(this).datepicker('setDate', new Date(year, month, 1));
}
}
};
$scope.setExpireDate = function() {
$(".ui-datepicker-calendar").hide();
$("button.ui-datepicker-current").css("display", "none");
};
这里有一个角度的版本:
在日期选择器选项中使用minMode:'month',它将起作用