문제

To un-subscribed from $broadcast in $on, one can do

var cleanUp = $rootScope.$on('myBroadcast', function(){ ... });
cleanUp();

Is there a way to re-subscribe once you have called cleanUp()?

도움이 되었습니까?

해결책

function foo () {
  return $rootScope.$on('myBroadcast', function(){ ... });
}
var cleanup = foo(); // listen

// somewhere down the road
cleanup(); // unlisten

// somewhere down the road
foo(); // listen again
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top