2

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?

1 Answer 1

5

you can display the date picker only after daysAvailable arrive:

<div ng-show="daysAvailable">
    <uib-datepicker  ng-model="date" ng-change="change()"  date-disabled="disabledDates(date,mode)"></uib-datepicker>
</div>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.