1

I have defined a directive that uses ui.calendar as sub directive:

angular.module('calendar.availability')
.directive('calendarAvailability', ['$http','$modal','$log', function($http,$modal,$log) {
        return {
        restrict: 'E'
        , replace: true
        , template: '<div><div ui-calendar="uiConfig.calendar" ng-model="eventsources"></div></div>'
        , scope: {
             availability: '=',
             delegation: '='
        }
        , link: function($scope, elm, attrs, ctrl) {
            $scope.eventsources=[];
            var removeAvailabilitySkeleton = function() {
                $scope.eventsources[0] = [];
            };
            $scope.$watch('availability', function(n, o) {
               if (n == o) return;
               removeAvailabilitySkeleton();
               if (n == 0) return;
               $http.get('ws/availability.php', {params: {doctor: $scope.availability,delegation: $scope.delegation}})
                .success(function(xhr) {
                $scope.eventsources[0] = xhr;
               });
            });
            //........... event handlers

            $scope.uiConfig = {
            calendar: {
                editable: true,
                selectable: true,
                selectHelper: true,
                weekends: false,
                defaultView: 'agendaWeek',
                unselectCancel: '.eventeditor',
                allDaySlot: false,
                slotEventOverlap: false,
                dayNames: ['domingo', 'lunes', 'martes', 'miercoles', 'jueves', 'viernes', 'sabado'],
                dayNamesShort: ['dom', 'lun', 'mar', 'mie', 'jue', 'vie', 'sab'],
                header: {
                left: 'month agendaWeek agendaDay',
                center: 'title',
                right: 'today prev,next'
                },
                dayClick: $scope.alertEventOnClick,
                eventDrop: $scope.alertOnDrop,
                eventResize: $scope.alertOnResize,
                select: $scope.selectRange
            }
            };
        }

        }
    }])

the problem is that, at render time, the sub directive ui.calendar don't find the ng-model eventsources (is undefined) and throws error. Any help is apreciated

1

0

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.