Im using Angular 1.5.6.
I have a directive to double-check:
angular.module('redMatter.analyse')
.directive('iosDblclick',
function () {
var DblClickInterval = 300;
var firstClickTime;
var waitingSecondClick = false;
return {
restrict: 'A',
link: function (scope, element, attrs) {
element.bind('click', function (e) {
if (!waitingSecondClick) {
firstClickTime = (new Date()).getTime();
waitingSecondClick = true;
setTimeout(function () {
waitingSecondClick = false;
}, DblClickInterval);
}
else {
waitingSecondClick = false;
var time = (new Date()).getTime();
if (time - firstClickTime < DblClickInterval) {
scope.$apply(attrs.iosDblclick);
}
}
});
}
};
});
I use this here:
<div ios-dblclick="onDoubleClick($event, graph)" ></div>
graph
is an object inside a directive ng-repeat
. In onDoubleClick, I need access to $event
:
$scope.onDoubleClick = function($event, graph){
console.log('in onDoubleClick and arguments are ', arguments);
var element = $event.srcElement;
However, I am not sure how to pass the event from the directive to onDoubleClick
. In the console log, the arguments are output as:
[undefined, Object]
Where Object
graph
. How can I also convey an event?
source
share