hi Neil

You might need to be a bit more specific about what you are trying to 
achieve.  

In general, AngularJS helps you to avoid adding any listeners to your code 
directly e.g. instead of adding an on-click event listener directly, you 
would use an ng-click attribute on the element....

// add event listener to tvar el = document.getElementById("someelement");
el.addEventListener("click", someFunction, false);

<div ng-click="someFunction()">

If you are writing directives and you are familiar with JQuery,  you can 
add listeners on elements in the link function using a JQuery syntax...


   1. return function(scope, *element*, attr) {
   2. var startX = 0, startY = 0, x = 0, y = 0;
   3.  
   4. *element*.on('mousedown', function(event) {
   5. // Prevent default dragging of selected content
   6. event.preventDefault();
   7. startX = event.pageX - x;
   8. startY = event.pageY - y;
   9. $document.on('mousemove', mousemove);
   10. $document.on('mouseup', mouseup);
   11. });


(from https://code.angularjs.org/1.2.16/docs/guide/directive)

If you want to want your client to listen for events from the server, then 
you might want to use a socket implementation with an angular wrapper 
like angular-socket-io (https://github.com/btford/angular-socket-io)

HTH

Michael

On Thursday, May 22, 2014 4:33:31 PM UTC+10, Neil Camara wrote:
>
> Hi folks,
>
> What is the addListener equivalent in AngularJS? A plunkr example would be 
> awesome too!
>
> Thanks in advance!
>
> Neil
>

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to