Is there a way to know what dependencies were injected into my Angular module?
angular.module('myModule', [
'ui.bootstrap'
])
.controller('myController', [function () {
// var dependencies = Magic.dependencies;
// console.log(dependencies);
}]);
In your controller, if you inject
$window
, you can dig for the dependencies, specifically, there exists a.requires
on your module. To do this, you can either declare your module as a globalvar
so we can find it on our$window
, in this case, let's call itapp
- or - you can bypass globals and$window
and callangular.module('myModule').requires
directly.ngRoute
as well to prove the array of dependencies that will be discoverable.JSFiddle Link - working example
Note - If leveraging globals, you can simply call the
window
as such:window.app.requires
- without injecting$window
. However, see the AngularJS $window docs to understand why$window
is preferred.