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.
So at the moment I have this in app.js:
'use strict';
// Declare app level module
var app = angular.module('app', ['ngRoute']).config(['$routeProvider', '$locationProvider', function($routeProvider, $locationProvider) {
// Possible routes can go here
}]);
And this in controllers.js:
app.controller('DownloadsController', function ($scope) {
});
I want to be able to add downloads in my application, so I'd write a $scope.addDownload = function() { ... } in the DownloadsController. That will work, however I'd like to be able to add downloads anywhere in my application, which means calling that addDownload() function no matter what controller I'm in.
Can I define a global controller that holds the addDownload() function and be able to call that function from all of my controllers?