Why do we use $rootScope.$broadcast in AngularJS? Last Updated : 02 Aug, 2024 Comments Improve Suggest changes Like Article Like Report The $rootScope.$broadcast is used to broadcast a "global" event that can be caught by any listener of that particular scope. The descendant scopes can catch and handle this event by using $scope.$on.Syntax:$rootScope.$broadcast(name, args)$scope.$on(name, listener);Parameter value:listener: It is used to specify the function to call when the event is caught.Approach:Create a ParentController from which you would want to raise/broadcast an event.Use $rootScope.$broadcast in AngularJS to broadcast the event from the ParentController.Create a ChildController or an ExternalController (i.e., not a direct descendant of the ParentController) to catch and handle the event.Use $scope.$on in AngularJS to catch the respective event.Example: This example uses $rootScope.$broadcast to raise an event. HTML <!DOCTYPE html> <html> <head> <script src= "http://ajax.googleapis.com/ajax/libs/angularjs/1.7.8/angular.js"> </script> <script type="text/javascript"> let app = angular.module('app', []); app.controller('ParentController', function ( $rootScope, $scope) { $scope.broadcastMessage = function () { $rootScope.$broadcast('newEvent', { message: $scope.parentMessage }); }; }); app.controller('ChildController', function ($scope) { $scope.$on('newEvent', function (event, args) { $scope.message = args.message; }); }); app.controller('ExternalController', function ($scope) { $scope.$on('newEvent', function (event, args) { $scope.message = args.message; }); }); </script> <style type="text/css"> h1, h2, code { color: green; } p { color: green; display: inline-block; } div { border-color: black; border-style: solid; padding: 10px; } </style> </head> <body ng-app="app"> <h1>GeeksforGeeks</h1> <h3>AngularJS $rootScope.$broadcast</h3> <div ng-controller="ParentController"> <h1>Parent Controller</h1> <input ng-model="parentMessage"> <button ng-click="broadcastMessage()"> Broadcast Message </button> <br><br> <div ng-controller="ChildController"> <h2>Child Controller</h2> <p>Message :</p> <code>{{message}}</code> </div> </div><br><br> <div ng-controller="ExternalController"> <h1>External Controller</h1> <p>Message :</p> <code>{{message}}</code> </div> </body> </html> Output: Create Quiz Comment R rohanr Follow 0 Improve R rohanr Follow 0 Improve Article Tags : Web Technologies AngularJS AngularJS-Questions Explore AngularJS BasicsAngularJS Tutorial 5 min read Introduction to AngularJS 4 min read Angular CLI | Angular Project Setup 3 min read AngularJS Expressions 2 min read AngularJS Modules 3 min read AngularJS ng-model Directive 4 min read AngularJS Data Binding 4 min read AngularJS Controllers 3 min read AngularJS | Scope 2 min read AngularJS Services 4 min read AngularJS | AJAX - $http 3 min read AngularJS | Tables 2 min read AngularJS Select Boxes 2 min read AngularJS SQL 3 min read AngularJS HTML DOM 2 min read AngularJS Events 3 min read AngularJS | Forms 3 min read AngularJS Form Validation 3 min read AngularJS | API 2 min read AngularJS and W3.CSS 2 min read AngularJS Includes 3 min read AngularJS Animations 1 min read AngularJS | Application 3 min read AngularJS DirectivesAngularJS Directives 9 min read AngularJS ng-app Directive 1 min read AngularJS ng-bind Directive 2 min read AngularJS ng-bind-html Directive 2 min read AngularJS ng-bind-template Directive 2 min read AngularJS ng-blur Directive 1 min read AngularJS ng-change Directive 2 min read AngularJS ng-checked Directive 2 min read AngularJS ng-class Directive 2 min read AngularJS ng-class-even Directive 2 min read AngularJS ng-class-odd Directive 2 min read AngularJS ng-click Directive 2 min read AngularJS ng-cloak Directive 2 min read AngularJS ng-controller Directive 2 min read AngularJS Directives Complete Reference 2 min read AngularJS FiltersAngularJS | Filters 7 min read AngularJS currency Filter 2 min read AngularJS | date Filter 2 min read AngularJS filter Filter 3 min read AngularJS json Filter 2 min read AngularJS limitTo Filter 2 min read AngularJS lowercase Filter 1 min read AngularJS number Filter 1 min read AngularJS orderBy Filter 4 min read AngularJs uppercase Filter 1 min read AngularJS Converting FunctionsAngularJS angular.lowercase() Function 2 min read AngularJS angular.uppercase() Function 1 min read AngularJS angular.forEach() Function 1 min read AngularJS Comparing FunctionsAngularJS angular.isArray() Function 2 min read AngularJS angular.isDate() Function 2 min read AngularJS angular.isDefined() Function 2 min read AngularJS angular.isElement() Function 2 min read AngularJS angular.isFunction() Function 2 min read AngularJS angular.isNumber() Function 2 min read AngularJS angular.isObject() Function 2 min read AngularJS | angular.isString() Function 1 min read AngularJS angular.isUndefined() Function 2 min read AngularJS angular.equals() Function 2 min read AngularJS angular.toJson() Function 2 min read AngularJS QuestionsHow to bundle an Angular app for production? 4 min read How to add many functions in one ng-click directive? 2 min read How to directly update a field by using ng-click in AngularJS ? 3 min read How to Add Dynamic Options for Multiple Selects Inside ng-repeat Directive ? 3 min read How to detect when an @Input() value changes in Angular? 3 min read How to open popup using Angular and Bootstrap ? 2 min read How to reload or re-render the entire page using AngularJS? 2 min read How to add input fields dynamically on button click in AngularJS ? 2 min read How to Create Button Dynamically with Click Event in Angular ? 2 min read How to use jQuery in Angular ? 2 min read AngularJS Examples 2 min read Like