2015-02-03 4 views
4

AngularJS에서 DOM 이벤트의 네임 스페이스를 어떻게 지정합니까? mouseup에 후Angular DOM 이벤트 네임 스페이스

$document.on('mousemove'); 
$document.on('mouseup'); 

내가 할 :

$document.off('mousemove'); 
$document.off('mouseup'); 

그리고

다음 다른 지침이 작동하지 않는, 이벤트가 파괴 되었기 때문에

나는 문서에 마우스 이벤트를 바인딩 할 몇 가지 지침이있다.

on() — Does not support namespaces, selectors or eventData 

글쎄,하지만 난 제거 할 이벤트 대상 event namespaces 필요하다고 생각 : angular.element에 대한 각도의 문서에서

가 기록됩니다. 그래서 내가 무엇을해야하니?

+1

그러면 특정 처리기를 제거하는 것은 어떻습니까? – raina77ow

+0

OMG, .off() 메서드 (facepalm)의 추가 매개 변수를 잊어 버렸습니다. 그것은 작동합니다. 귀하의 의견을 대답, 내가 받아 들일 것입니다. – artuska

답변

4

jqLite가 네임 스페이스를 지원하지 않지만 적어도 .off()handler 매개 변수와 함께 사용하여 제거해야하는 수신기를 지정할 수 있습니다. 예 :

function mouseMoveHandler() { 
    // do some stuff 
} 
$document.on('mousemove', mouseMoveHandler); 
// ... and later on 
$document.off('mousemove', mouseMoveHandler); 
관련 문제