Skip to content

Instantly share code, notes, and snippets.

@sushantdhiman
Created June 4, 2015 07:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sushantdhiman/0b1957bfb096c1addccf to your computer and use it in GitHub Desktop.
Save sushantdhiman/0b1957bfb096c1addccf to your computer and use it in GitHub Desktop.
Bootstrap.UI Date Picker Angular Addon
/*
Just Add this addon on parent or same level of datepicker-ui.
current-date will automatically be updated with date selected by keyboard
*/
/** Enhance the ui.datepicker to able to read the selected date from ui.datepicker **/
angular.module('directives.',['ui.bootstrap.datepicker'])
.directive('ariaAddon',['$timeout',function($timeout){
return {
restrict : 'A',
scope : {
'currentDate' : "="
},
link:function(scope, elm, attrs){
$timeout(function(){
var popup = elm.find('[datepicker]');
var datepickerController = angular.element(popup).controller('datepicker');
var datepickerScope = angular.element(popup).isolateScope();
datepickerScope.$watch(function(){
return datepickerController.activeDate;
},function(newValue,oldValue){
scope.currentDate = oldValue;
})
},0);
}
};
}])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment