我在应用中使用Angular ui日历。
一切正常。日历已显示,但事件未出现在日历中。
这是我的代码:-
$timeout(function() {
$scope.events = [
{
title: 'Long Event',
start: '2019-01-10'
}
];
$scope.eventSources = [$scope.events];
return $scope.uiConfig = {
calendar: {
height: 450,
editable: true,
header: {
left: 'title',
center: '',
right: 'today prev,next'
}
}
};
},5000);
这里我正在使用超时,因为我希望加载日历有一些延迟。
这是我的HTML代码:-
<div ui-calendar="uiConfig.calendar" class="span8 calendar" ng-model="events" calendar="myCalendar" style="height:700px;"></div>
文档建议您应该给一个名为eventSources的数组。我已经给了,但是没有用。
请指出我在做什么错。
这是屏幕截图:-
答案 0 :(得分:0)
您正在5秒钟后初始化作用域变量,您的日历获取了(\b(?i:jack|jill|john)\b.*){2,}
变量,因此,如果您检查控制台是否有错误。您需要做的就是仅在此变量加载时才日历undefined
。
所以,您需要
defined
如果定义了此变量,则只会显示您的日历。
您的div应该看起来像这样
ng-if="uiConfig!==undefined"
这将确保在此变量具有某些值时进行初始化。