我在" full calender"的eventSources选项下发送令牌标头。在Angular中使用以下标题选项:
eventSources: [
{
url: '/api/schedules',
headers: JSON.parse($cookies['auth_headers']),
error: function () {
var $state = $injector.get('$state');
$state.transitionTo('page.login');
}
}
],
鉴于fullcalendar使用jQuery,我需要为每个请求刷新头文件。有没有办法用fullcalendar做到这一点?
答案 0 :(得分:1)
未经测试,但指定beforeSend
函数应该可以实现:
eventSources: [
{
url: '/api/schedules',
beforeSend: function(xhr) {
var headers = JSON.parse($cookies['auth_headers']);
for (var i in headers ) xhr.setRequestHeader(i, headers[i]);
},
error: function () {
var $state = $injector.get('$state');
$state.transitionTo('page.login');
}
}
],