Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Web Technology by (47.6k points)

Now that the performance difference between $broadcast and $emit has been eliminated, is there any reason to prefer $scope.$emit to $rootScope.$broadcast?

They are different, yes.

$emit is restricted to the scope hierarchy (upwards) - this may be good if it fits your design, but it seems to be a rather arbitrary restriction.

$rootScope.$broadcast works across all that choose to listen to the event, which is a more sensible restriction in my mind.

Am I missing something?

1 Answer

0 votes
by (106k points)

Both are different $emit dispatches an event upwards through the scope hierarchy, while $broadcast dispatches an event downwards to all child scopes.

Related questions

0 votes
1 answer
asked Aug 29, 2019 in Web Technology by Sammy (47.6k points)
0 votes
1 answer
asked Aug 31, 2019 in Web Technology by Sammy (47.6k points)
0 votes
1 answer

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...