I am using ui-date directive (https://github.com/angular-ui/ui-date).
This UI Calendar component is getting Date by default. Can I get only month and year without dates.
How to get only month and year?
I don't know ui-date directive, but I had exactly the same need than you.
You can use eternicode's fork of bootstrap-datepicker and look for the min view mode parameter which will fit your need.
Following Code work for me. Thanks
$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");
};
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With