After spending some time trying to find the right way to get this, and reading the datepicker directive and the source code of the controller, I could not find a dirty way to get the current month, so here is a very hacky way to do this.
Warning, future versions of Angular -UI Bootstrap may violate this approach
AngularJS decorators. , :
angular.module('myApp', [
'ui.bootstrap'
])
.config(function($provide) {
$provide.decorator('datepickerDirective', function($delegate) {
var directive = $delegate[0];
var directiveCompile = directive.compile;
directive.compile = function(tElement, tAttrs) {
var link = directiveCompile.apply(this, arguments);
return function(scope, element, attrs, ctrls) {
link.apply(this, arguments);
var originalMove = scope.move;
scope.move = function(direction) {
originalMove.apply(this, arguments);
var currentMonth = this.title;
scope.$emit('datepicker.monthChanged', currentMonth);
}
}
};
return $delegate;
});
})
datepicker.monthChanged:
$scope.$on('datepicker.monthChanged', function(event, newVal) {
$scope.currentMonth = newVal;
})
datepicker $scope, , , , , this, move. move , .
plunkr : http://plnkr.co/edit/iWJWjM8nCsh5TMupNioo?p=preview