답변

0

그래서이 문제를 해결할 수있었습니다. 우리는

angular.module('ui.bootstrap.datepicker') 
.config(function ($provide) { 
    $provide.decorator('uibDatepickerDirective', function ($delegate, $timeout) { 
     var directive = $delegate[0]; 
     var link = directive.link; 


     angular.extend(directive.scope, { 
      visibleDates: '=?' 
     }); 


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

       var datepickerCtrl = ctrls[0]; 

       datepickerCtrl.getVisibleDates = function() { 
        var year = this.activeDate.getFullYear(), 
        month = this.activeDate.getMonth(), 
        firstDayOfMonth = new Date(this.activeDate); 

        firstDayOfMonth.setFullYear(year, month, 1); 

        var difference = this.startingDay - firstDayOfMonth.getDay(), 
         numDisplayedFromPreviousMonth = difference > 0 ? 
         7 - difference : -difference, 
         firstDate = new Date(firstDayOfMonth); 

        if (numDisplayedFromPreviousMonth > 0) { 
         firstDate.setDate(-numDisplayedFromPreviousMonth + 1); 
        } 
        return this.getDates(firstDate, 42);; 
       } 

       var firstTime = true; 

       $timeout(function() { 
        scope.$watch("activeDt", function() { 
         var newValues = datepickerCtrl.getVisibleDates(); 
         if (firstTime) { 
          scope.visibleDates = newValues; 
          firstTime = false; 
          return; 
         } 
         if (newValues[0].getYear() !== scope.visibleDates[0].getYear() || 
          newValues[0].getMonth() !== scope.visibleDates[0].getMonth() || 
          newValues[0].getDate() !== scope.visibleDates[0].getDate()) { 
          scope.visibleDates = newValues; 
         } 
        }); 
       }); 


      } 
     }; 
     return $delegate; 
    }); 
}); 

uibDatepickerDirective

을 확장 할 필요가 그리고 지시 자체는 우리가이 사십이일을 저장할 변수에 atribute 볼 수-날짜와 지점을 통과해야합니다.

<span uib-datepicker visible-dates="visibleDates" datepicker- ng-model="datePicked"></span> 

우리가 날짜 선택기에서 달을 변경할 수 있지만 우리는 같은 달 (같은 눈에 보이는 날짜)에 activeDate (scope.activeDt)를 변경하는 경우, 그것은 변하지 남아있을 것입니다 경우 우리가 visibleDates 업데이트됩니다 이런 식으로 (그 42).