Give an example for Rootscope in AngularJS?
Answer / Anjali Verma
$rootScope can be used to broadcast and listen to events across different scopes. Here's an example:
```javascript
// Broadcasting event from a child scope
$scope.$broadcast('eventName', data);
// Listening to the event in a parent scope
$rootScope.$on('eventName', function(event, data) {
console.log(data);
});
| Is This Answer Correct ? | 0 Yes | 0 No |
What is the use of $locale service in angularjs?
What is the use of @inject()?
What is innerhtml in angular?
What is dependency injection (di)?
What is compile function in angularjs?
How angular apps prevent this attack?
What is angular 2?
Explain ng-hide directive?
Which framework is best for front end?
What are the difference between angular 6 and angular 7?
What is Service in AngularJS?
What is callback function?