title: AngularJS global controller
body: <p>In my Angular application I have a few functions which I think should be in a global controller. In server-side MVC frameworks there's usually a global controller that all other controllers extend, which is where I'd put these functions. I'm wondering if there's anything like that for Angular.</p>
  
  <p>So at the moment I have this in <code>app.js</code>:</p>
  
  <pre><code>'use strict';
  
  // Declare app level module
  var app = angular.module('app', ['ngRoute']).config(['$routeProvider', '$locationProvider', function($routeProvider, $locationProvider) {
  
      // Possible routes can go here
  
  }]);
  </code></pre>
  
  <p>And this in <code>controllers.js</code>:</p>
  
  <pre><code>app.controller('DownloadsController', function ($scope) {
  
  });
  </code></pre>
  
  <p>I want to be able to add downloads in my application, so I'd write a <code>$scope.addDownload = function() { ... }</code> in the <code>DownloadsController</code>. That will work, however I'd like to be able to add downloads anywhere in my application, which means calling that <code>addDownload()</code> function no matter what controller I'm in.</p>
  
  <p>Can I define a global controller that holds the <code>addDownload()</code> function and be able to call that function from all of my controllers?</p>