Mrs*_*ody 0 javascript fullcalendar angularjs
我使用https://github.com/angular-ui/ui-calendar来使用Angularjs中的FullCalendar.
它显示日历并显示没有错误;
<div class="calendar" ng-model="eventSources" id="eventCalendar" calendar="calendar" config="uiConfig.calendar" ui-calendar="uiConfig.calendar"></div>
Run Code Online (Sandbox Code Playgroud)
但它不会显示事件,我不确定我是否正确,但它没有显示错误,我搜索互联网,但还没有找到解决方案.任何人都可以给我一个暗示,为什么它不起作用?
这是代码片段:
var calApp = angular.module('usercalapp', ['ui.bootstrap','dialogs','ngCookies','ui.calendar']);
calApp.controller('UserCtrl', function ($scope, $http, $rootScope, $timeout,,$dialogs,$cookieStore,$compile,uiCalendarConfig)
{
$scope.eventSources = [];
$scope.calendar = $('#calendar');
$scope.uiConfig = {
calendar : {
height: 450,
editable: true,
header: {
left: 'month basicWeek basicDay',
center: 'title',
right: 'today prev, next'
},
dayClick: $scope.alertEventOnClick,
eventDrop: $scope.alertOnDrop,
eventResize: $scope.alertOnSize
}
};
$scope.cal_func = function()
{
var date = new Date();
var d = date.getDate();
var m = date.getMonth();
var y = date.getFullYear();
$scope.eventSources = [
{
title: 'All Day Test Event',
start: new Date(y, m, 1)
},
{
title: 'Long Test Event',
start: new Date(y, m, d - 5),
end: new Date(y, m, d - 2)
},
{
title: 'Test Birthday Party',
start: new Date(y, m, d + 1, 19, 0),
end: new Date(y, m, d + 1, 22, 30),
allDay: false
}];
$scope.calendar.fullCalendar('refetchEvents');
};
$scope.showColorPicker = function(index)
{
$cookieStore.showuserid = index;
dlg = $dialogs.create('/dialogs/pickColor.html','pickColorCtrl',{},{key:false ,back:'static'});
dlg.result.then(function()
{
$scope.cal_func();
});
};
....
Run Code Online (Sandbox Code Playgroud)
所以我希望用户选择一种颜色,然后3个事件应该出现在日历中,但没有任何反应......
在这里,eventSources您已经直接输入了活动.
您应该做的是提供存储事件的阵列列表.像这样的东西:
$scope.eventSources = [$scope.myEvents, $scope.someOtherArray, $scope.otherEvents];
在$scope.myEvents,你可以把你的事件.
$scope.myEvents = [
{
title: 'All Day Test Event',
start: new Date(y, m, 1)
},
{
title: 'Long Test Event',
start: new Date(y, m, d - 5),
end: new Date(y, m, d - 2)
},
{
title: 'Test Birthday Party',
start: new Date(y, m, d + 1, 19, 0),
end: new Date(y, m, d + 1, 22, 30),
allDay: false
}
];
Run Code Online (Sandbox Code Playgroud)
$scope.someOtherArray, $scope.otherEvents 可以是事件的其他来源.
$scope.someOtherArray = [];
$scope.weeklyEvents = {
color: '#656565',
textColor: 'white',
events: []
};
$scope.otherEvents = {
color: '#B2B2B2',
textColor: 'black',
events: []
};
Run Code Online (Sandbox Code Playgroud)
您可以修改代码以使用上述两种方法之一(访问这些链接).
| 归档时间: |
|
| 查看次数: |
3775 次 |
| 最近记录: |