In Angular, $ scope inherits, not controllers.
Each controller created by the ng controller creates a new $ scope (childScope), which inherits from the $ scope in which it exists. I think you can read this answer to understand how exactly $ scope (prototypical inheritance) is inherited.
Please, you do not need to use $ parent to get the name of the parent region $, for example, if you removed $ scope.name from ItemController and tried to link {{name}} your template will be compiled and linked, and the value {{name}} will be "SecondController" in your example.
As for broadcasting $, you should try to avoid using $ rootScope. $ broadcast, because it will send an event to all areas of $ in your application. I'm not sure what your use case is, but if you want, for example, to execute the method defined in your "MainController", you can simply call it, for example,
angular.module('app', []); angular.module('app') .controller('MainController', function($scope) { $scope.name = "MainController"; $scope.doSomething = function() { console.log("Do it"); } }) .controller('SecondController', function($scope) { $scope.name = "SecondController"; $scope.list = [ {'name': 'aaa'} ]; }) .controller('ItemController', function($scope) { $scope.name = "ItemController"; $scope.myDad = $scope.$parent.name; $scope.myGrandpa = $scope.$parent.$parent.name; $scope.clickItem = function() { console.log("Item clicked"); $scope.doSomething();
source share