function foo () {
return $rootScope.$on('myBroadcast', function(){ ... });
}
var cleanup = foo(); // listen
// somewhere down the road
cleanup(); // unlisten
// somewhere down the road
foo(); // listen again
AngularJS $on - Re-subscribe a un-subscribed broadcast
-
13-07-2023 - |
Pergunta
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()
?
Solução
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow