Skip to content

Instantly share code, notes, and snippets.

@cgmartin
Last active May 21, 2018 21:42

Revisions

  1. cgmartin revised this gist Dec 14, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion datepicker.decorator.js
    Original file line number Diff line number Diff line change
    @@ -3,7 +3,7 @@
    * refreshing the datepicker view (and rerunning invalid dates function)
    * upon an event trigger: `$scope.$broadcast('refreshDatepickers');`
    *
    * (Works with inline and popup)
    * Works with inline and popup. Include this after `ui.bootstrap` js
    */
    angular.module('ui.bootstrap.datepicker')
    .config(function($provide) {
  2. cgmartin revised this gist Dec 14, 2014. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions datepicker.decorator.js
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    /**
    * Decorates the ui-bootstrap datepicker directive's controller to allow
    * refreshing the datepicker view (and rerunning invalid dates function)
    * upon an event trigger: `$scope.$broadcast('refreshDates');`
    * upon an event trigger: `$scope.$broadcast('refreshDatepickers');`
    *
    * (Works with inline and popup)
    */
    @@ -19,8 +19,8 @@ angular.module('ui.bootstrap.datepicker')
    var ngModelCtrl = ctrls[1];

    if (ngModelCtrl) {
    // Listen for 'refreshDates' event...
    scope.$on('refreshDates', function refreshView() {
    // Listen for 'refreshDatepickers' event...
    scope.$on('refreshDatepickers', function refreshView() {
    datepickerCtrl.refreshView();
    });
    }
  3. cgmartin created this gist Dec 14, 2014.
    31 changes: 31 additions & 0 deletions datepicker.decorator.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,31 @@
    /**
    * Decorates the ui-bootstrap datepicker directive's controller to allow
    * refreshing the datepicker view (and rerunning invalid dates function)
    * upon an event trigger: `$scope.$broadcast('refreshDates');`
    *
    * (Works with inline and popup)
    */
    angular.module('ui.bootstrap.datepicker')
    .config(function($provide) {
    $provide.decorator('datepickerDirective', function($delegate) {
    var directive = $delegate[0];
    var link = directive.link;

    directive.compile = function() {
    return function(scope, element, attrs, ctrls) {
    link.apply(this, arguments);

    var datepickerCtrl = ctrls[0];
    var ngModelCtrl = ctrls[1];

    if (ngModelCtrl) {
    // Listen for 'refreshDates' event...
    scope.$on('refreshDates', function refreshView() {
    datepickerCtrl.refreshView();
    });
    }
    }
    };
    return $delegate;
    });
    });