Using eventjs with broken corners

Greetings Overflowers,

Using the angularjs binding function to register event handlers by element does not work if eventjs script!

I got the impression that eventjs will replace the default addEventListener function, which will be used by the angularjs binding function without any problems.

I tried to use eventjs before and after angularjs, but no luck.

Any ideas?

Yours faithfully

+4
source share
2 answers

It seems that the event message becomes something angular does not expect. (I don’t know the details, I will wait for a better answer from the community ...)

A simple workaround, this will work if you use jQuery (source code before angularJs)

+1
source

I managed to bind events, but soon I found that some events do not work with angular.element.bind() . For example, in the case of a click event, I had to use the syntax Event.add() .

Here's what it looks like:

 angular.module('myApp', []).config(function(){ Event.modifyEventListener = true; Event.modifySelectors = true; }).controller('SomeCtrl', function($scope){ $scope.eventType = ""; }).directive('foo', function($log){ return { link: function(scope, elm, attr){ // here it is using the 'bind' syntax elm.bind('mousedown mouseup mouseenter mouseleave', function(evt){ $log.debug(evt); scope.eventType = evt.type; scope.$apply(); }); // here it is using Event.add Event.add(elm[0], 'click', function(evt, context) { $log.debug(context); scope.gesture = context.gesture + ', ' + context.pointerType; scope.$apply(); }); } }; }); 

Here you can see the demo: http://plnkr.co/edit/FLMckw?p=preview

+1
source

Source: https://habr.com/ru/post/1488863/


All Articles