javascript - customClass in Angularjs uib-datepicker depends on a promise -


i'm using angularjs ui bootstap datepicker, , trying set custom classes days, it's shown @ example on provided page

this part of mine controller

var vm = this; ... vm.dateoptions = {         customclass: gettestdaysclass; }; ... function gettestdaysclass(data) {     var date = data.date,         mode = data.mode;     if (mode === 'day') {         var daytocheck = new date(date).sethours(0,0,0,0);         (var = 0; < vm.testdays.length; i++) {             var currentdat = new date(vm.testdays[i].date).sethours(0,0,0,0);             if (daytocheck === currentdat) {                 return vm.testdays[i].status;             }         }     }     return ''; } 

and html

<uib-datepicker          datepicker-options="user.dateoptions"> </uib-datepicker> 

the problem array vm.testdays back-end call service. , isn't in controller's scope yet, when page loaded, application crashes following error. give me hint how solve this? way make datepicker wait promise resolve.

i had same problem, , used "ng-if" tag wrapper div variable changed value true when had got dates.

in html:

<div ng-if="calendarloaded">     <uib-datepicker ng-model="dt" class="well well-sm" datepicker-options="options"></uib-datepicker> </div> 

in directive:

$scope.calendarloaded = false; $http.get(...) .then(function(response) {   $scope.calendarloaded = true;   {... other code here ...} }); 

i hope can you.


Comments

Popular posts from this blog

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -

asp.net mvc - breakpoint on javascript in CSHTML? -