In my Angular application, I have several functions that I think should be in the global controller. In server-side MVC infrastructures, there is usually a global controller that all other controllers extend, and that is where I would put these functions. I am wondering if there is anything like this for Angular.
So, at the moment I have this in app.js:
'use strict';
var app = angular.module('app', ['ngRoute']).config(['$routeProvider', '$locationProvider', function($routeProvider, $locationProvider) {
}]);
And this is in controllers.js:
app.controller('DownloadsController', function ($scope) {
});
I want to be able to add downloads to my application, so Iβll write $scope.addDownload = function() { ... }to DownloadsController. This will work, however, I would like to be able to add downloads anywhere in my application, which means calling this function addDownload()no matter which controller I enter.
, addDownload() ?