I have an AngularUI Bootstrap calendar with a disabledDates function
<uib-datepicker ng-model="date" ng-change="change()" date-disabled="disabledDates(date,mode)"></uib-datepicker>
This is the function:
$scope.disabledDates = function (date, mode) {
if ($scope.daysAvailable != null) {
return mode === 'day' && $scope.daysAvailable.indexOf(date.getDay() + 1) == -1;
}
}
$scope.daysAvailable is loaded from the server with an $http request
$scope.init = function () {
return $http.get('/OrderEntry/GetAvailableDays', { params: { method: shipMethod, state: state, zip: zip } }).then(function (data) {
$scope.daysAvailable data.data;
});
}
The problem is that my HTML is loading (and calling disabledDates() before the results are returned from the server and loaded in the controller init()
How can I prevent the calendar load until the data is returned?