AngularJS supports the publish and subscribe mechanism to communicate among modules. It uses
$on to implement, publish and subscribe design pattern. Using
$broadcast, a message can be published inside the AngularJS application. Using the
$on method, a published message can be subscribed.
When a message is published using
$emit, it starts propagating from the current scope to the upper level scope and continues up to the application scope, which is
$rootScope. The following code shows the syntax of the
$emit method to publish a message:
In the previous code, you can see ...