Search code examples
javascriptangularjsscoperootscopeemit

What is difference between $scope.$emit and $rootScope.$emit?


What is difference between $scope.$emit and $rootScope.$emit ?

I'm using it to emit from a directive to controller and it works un both ways!


Solution

  • $scope.$emit allows the current scope and parents (including the rootScope) to listen for an event.

    $rootScope.$emit allows only the rootScope to listen for a specific event.