Can I get a list of all registered directives, services, controllers, etc. at runtime . . . ?
相关问题
- angularJS: ui-router equivalent to $location.searc
- Separate AngularJS Controllers Into Separate Files
- Angular ngAnimate not working first time on page l
- Ionic Spinner not showing up
- Upload file to Google Cloud Storage using AngularJ
相关文章
- Passing variable through URL with angular js
- Watch entire object (deep watch) with AngularJS
- Angular ng-if change span text
- Can ng-show directive be used with a delay
- AngularJS $routeParams vs $stateParams
- Multiple parameters in AngularJS $resource GET
- How to set class/style of accordion heading in Ang
- PUT to S3 with presigned url gives 403 error
Try this:
You can get a list of the providers (ie services/directives/controllers/factories/etc) for each module, although the list is kind of cryptic.
Say you have the following:
Then the
mod
variable will contain an attribute calledmod._invokeQueue
that will contain an array of all the providers that are part of that module. The_invokeQueue
will look something like this:So you can search through that
mod._invokeQueue
for each provider that it contains.But that will only contain the list of providers for that specific module. If you want to get a list of all of the dependent modules, you will need to loop through the
mod.requires
array.If the module has module-level dependencies, like so:
Then the
mod
object will also have amod.requires
array that contains the names of those module dependencies, like so:Hope that helps.
Here's how you can get most services
Ie: constants, values, factories, services.
Now when you type in the console
allMyServices.
you'll get an auto-complete list of them.The function above can fail in certain situations where
angular.element(document).injector()
returns undefined. You can use the function below instead...Alternate Method
Now when you type in the console
allMyServices.
you'll get an auto-complete list of them.Note: With either method, be sure to replace
'MyApp'
with your module name.I've created a GitHub gist with some code that can output the dependencies in a Graphviz friendly format. Which means you should be able to visualize the dependency graph.
See https://gist.github.com/dlidstrom/a2f787cef41ea4fcb8aa74d459f49270.