Angular Controller Extend

Showing the extending controllers works and is useful and tidy

HTML

<body ng-app="new">
    <div ng-controller="aCtrl">{{text1 + " " + text2}}</div>
    
    <div ng-controller="cCtrl">{{text1 + " " + text2}}</div>
    
    <div ng-controller="xCtrl">{{text1 + " " + text2}}</div>
</body>

JavaScript

var multiApp = angular.module('new', []);

// create a controller and extend it
 multiApp.controller('aCtrl', ['$scope', '$controller', function ($scope, $controller) {
     $scope.text1 = 'Hello';

     angular.extend(this, $controller('bCtrl', {
         $scope: $scope
     }));
 }]);



// create another controller and extend it also
 multiApp.controller('cCtrl', ['$scope', '$controller', function ($scope, $controller) {
     $scope.text1 = 'Runner\'s';

     angular.extend(this, $controller('bCtrl', {
         $scope: $scope
     }));
 }]);

// muliple use controller

// and create another controller and extend it also
 multiApp.controller('xCtrl', ['$scope', '$controller', function ($scope, $controller) {
     $scope.text1 = 'Majc';

     angular.extend($controller('bCtrl', {
         $scope: $scope
     }), this);
     $scope.text2 = 'test';
 }]);


 multiApp.controller('bCtrl', ['$scope', function ($scope) {
     $scope.text2 = 'World!';
 }]);