2016-04-27 50 views
2

我有以下的jQuery的片段:我可以使用Angular将mouseup事件绑定到文档正文吗?

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(); 
     } 
    }); 

如果我点击外面哪些隐藏的元素。

我想用Angular做同样的事情,但我不确定如何实现它。

什么是像这样绑定事件到文档的角度方式?

+0

这有帮助吗? http://stackoverflow.com/questions/22360215/using-angular-how-do-i-bind-a-click-event-to-an-element-and-on-click-slide-a-s –

回答

0

是的!还记得AngularJS也使用jQuery Lite吗?

angular.element(document).bind('mouseup', function(){ 
    console.log('Hello!'); 
}); 
相关问题