2

I have the following jQuery snippet:

    jQuery(document).mouseup(function (e)
    {
        var container = jQuery('.dropDown');

        if (!container.is(e.target) // if the target of the click isn't the container...
            && container.has(e.target).length === 0) // ... nor a descendant of the container
        {
            container.hide();
        }
    });

Which hides an element if I click outside it.

I want to do the same thing using Angular, but I'm not really sure how to achieve it.

What is the Angular way of binding events like this to the document?

Daft
  • 10,277
  • 15
  • 63
  • 105
  • Does this help? http://stackoverflow.com/questions/22360215/using-angular-how-do-i-bind-a-click-event-to-an-element-and-on-click-slide-a-s – Asim K T Apr 27 '16 at 10:37

1 Answers1

0

Yes! Remember AngularJS also uses jQuery Lite?

angular.element(document).bind('mouseup', function(){
    console.log('Hello!');
});
Dipak
  • 11,930
  • 1
  • 30
  • 31