我已经定义了一个使用ui.calendar作为子指令的指令:
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
}
};
}
}
}])
问题在于,在渲染时,子指令ui.calendar找不到ng-model事件源(未定义)并抛出错误。 任何帮助都是apreciated