[英]angularjs $scope variable inside jquery bind method
I have been using Fullcalender directive in angularjs application. 我一直在angularjs应用程序中使用Fullcalender指令。 As I have been in the documentation there is double click handle exists in Fullcalender jquery plugin. 正如我在文档中所提到的,Fullcalender jquery插件中存在双击句柄。
Here is the ref: http://code.google.com/p/fullcalendar/issues/detail?id=375#makechanges 这是裁判: http : //code.google.com/p/fullcalendar/issues/detail? id= 375#makechanges
There is a suggestion for the double click is that we should used eventRedner event handler for registering double event. 双击的建议是,我们应该使用eventRedner事件处理程序注册两次事件。 As I did and got succeed but the problem is I wont be able to call $modal box inside bind method. 正如我所做的并获得成功,但问题是我将无法在bind方法内调用$ modal box。
Here is the code. 这是代码。
$scope.eventPopup = function(event,element){
console.log($scope);
element.bind('dblclick', function(e) {
console.log("double click" );
var modalInstance = $modal.open({
templateUrl: Drupal.settings.angularjsApp.basePath + '/ng_node/calender/popup',
controller: ModalInstanceCtrl,
scope: $scope
});
});
};
Calender configuration: 压光机配置:
$scope.uiConfig = {
calendar:{
height: 450,
editable: true,
eventStartEditable: false,
header:{
left: 'prev,next today',
center: 'title',
right: 'month,basicWeek,basicDay'
},
//eventClick: $scope.alertOnEventClick,
eventDrop: $scope.alertOnDrop,
eventResize: $scope.alertOnResize,
eventRender: $scope.eventPopup
}
};
Can any one suggest me what should I do? 谁能建议我该怎么办?
Thanks 谢谢
I have resolved that issue by using $apply() method in AngularJs. 我已经通过在AngularJs中使用$ apply()方法解决了该问题。
element.bind('dblclick',function(e) {
$scope.$apply(function(){
console.log(event_date._d);
var modalInstance = $modal.open({
templateUrl: Drupal.settings.angularjsApp.basePath + '/ng_node/calender/popup',
controller: ModalInstanceCtrl,
resolve:{
day: function (){
return event_date._d;
}
},
size: 'lg',
scope: $scope
});
});
});
$apply() function is used for jQuery binding. $ apply()函数用于jQuery绑定。
Thanks 谢谢
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.