Javascript 如何在jquery函数中调用typescript函数?
我不知道是否可以在jquery函数中调用typescript。如果可能,正确的方法是什么 这是我的组件 dayclick函数 这是我试图在上面的jquery函数中调用的模态函数Javascript 如何在jquery函数中调用typescript函数?,javascript,jquery,angular,typescript,Javascript,Jquery,Angular,Typescript,我不知道是否可以在jquery函数中调用typescript。如果可能,正确的方法是什么 这是我的组件 dayclick函数 这是我试图在上面的jquery函数中调用的模态函数 如果您不需要随附的此 您可以使用箭头功能: dayClick: (date, jsEvent, view)=> { this.addModal(); } 或者,您可以将外部此存储在变量中,以后再使用它 var self = this; // store here
如果您不需要随附的
此
您可以使用箭头功能:
dayClick: (date, jsEvent, view)=> {
this.addModal();
}
或者,您可以将外部此存储在变量中,以后再使用它
var self = this; // store here
dayClick: function(date, jsEvent, view) {
self.addModal(); // use here
}
编辑:
getCalendar(){
var self = this; // ******
calendarOptions:Object = {
height: 'parent',
fixedWeekCount : false,
defaultDate: '2017-03-01',
editable: true,
eventLimit: true, // allow "more" link when too many
dayClick: function(date, jsEvent, view) {
self.addModal(); // *********
},
success: function(doc) {
var events = [];
$(doc).find('event').each(function() {
events.push({
title: $(this).attr('title'),
start: $(this).attr('start') // will be parsed
});
});
},
eventAllow: function(dropLocation, draggedEvent) {
if (draggedEvent.id === '999') {
return dropLocation.isAfter('2017-03-22'); // a boolean
}
else {
return true;
}
}
};
@AlyssaAndrea如果您可以分享整个日单击功能,我将编辑我的答案,使其更精确。喜欢里面哪种角度的方法?我希望你能帮我this@AlyssaAndrea没问题,但是你能分享一下代码的外部方法吗?dayClick
?我已经编辑了上面的文章。或者您想从我的组件.ts获取我的全部代码?@AlyssaAndrea是的,但我看不出您在哪里使用包含dayClick的函数。我假设dayClick
只是您正在使用的库中的选项之一。在哪里/如何使用它很重要。如果不是太多,您可以添加整个代码,但我只需要查看dayClick
所在的封闭方法。
dayClick: (date, jsEvent, view)=> {
this.addModal();
}
var self = this; // store here
dayClick: function(date, jsEvent, view) {
self.addModal(); // use here
}
getCalendar(){
var self = this; // ******
calendarOptions:Object = {
height: 'parent',
fixedWeekCount : false,
defaultDate: '2017-03-01',
editable: true,
eventLimit: true, // allow "more" link when too many
dayClick: function(date, jsEvent, view) {
self.addModal(); // *********
},
success: function(doc) {
var events = [];
$(doc).find('event').each(function() {
events.push({
title: $(this).attr('title'),
start: $(this).attr('start') // will be parsed
});
});
},
eventAllow: function(dropLocation, draggedEvent) {
if (draggedEvent.id === '999') {
return dropLocation.isAfter('2017-03-22'); // a boolean
}
else {
return true;
}
}
};