December 2016 Entries

Angular $broadcast vs. $emit - diffs, pros and cons

Goal: There always seems to be confusion over when to use $broadcast vs. $emit and can be hard to remember the scope affected by which one. Of course this will also have an impact on performance. Details: In either case, $broadcast or $emit, Angular uses $rootScope.$on and $scope.$on to listen to these events. Which one to use is up to the how far you want to expose the listener or subscriber to dispatched events. $rootScope $emit dispatches events upwards only by traversing the scope hierarchy from ......