title: Defining angular controllers and component
body: <p>I'm trying to call a function from within one angular component's controller to another component's controller. I found <a href="https://stackoverflow.com/questions/29467339/how-to-call-function-in-another-controller-in-angularjs">this</a> answer, but the controllers are defined differently than what is shown in the tutorials I followed, so I'm confused as to how I'm supposed to reference the components and templates.</p>
  
  <p>Here is how I currently define one of my controllers based on the official angular tutorial</p>
  
  <pre><code>angular.
    module('moduleName').
    component('firstComponent', {
      templateUrl: 'url/to/template',
      controller: function FirstController($scope) {  
         //I want to call a function in SecondController here
      }
    });
  
  //in another component file
  angular.
    module('moduleName').
    component('secondComponent', {
      templateUrl: 'url/to/template',
      controller: function SecondController($scope) {  
         //function here which will be called
      }
    });
  </code></pre>
  
  <p>Say I re-structure them like in the example I linked above...</p>
  
  <pre><code>var app= angular.module("myApp",[]);
  
  app.controller('One', ['$scope', '$rootScope'
      function($scope) {
          $rootScope.$on("CallParentMethod", function(){
             $scope.parentmethod();
          });
  
          $scope.parentmethod = function() {
              // task
          }
      }
  ]);
  
  //in another file 
  var app= angular.module("myApp",[]);
  app.controller('two', ['$scope', '$rootScope'
      function($scope) {
          $scope.childmethod = function() {
              $rootScope.$emit("CallParentMethod", {});
          }
      }
  ]);
  </code></pre>
  
  <p>How am I supposed to reference each controller's component which they belong to, and their respective templates? I tried to write them like in the example I linked above, but nothing happened. I didn't get any errors, but literally nothing happened. Nothing was displayed on the page. It tried to write to the console, but nothing appeared. </p>