Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

List declared directives/controllers in AngularJS module

Tags:

Is there a way to list all of the directives and controllers that have been defined for a given angular module? For example, imagine I define three controllers in the 'main' module (i.e. angular.module('main').controller('MainCtrl',function() {...}). Is there are way to get the list of those three controllers?

like image 568
Viper Bailey Avatar asked Sep 24 '13 16:09

Viper Bailey


People also ask

Which directive is used for controller in Angular?

AngularJS ng-controller Directive The ng-controller directive adds a controller to your application. In the controller you can write code, and make functions and variables, which will be parts of an object, available inside the current HTML element. In AngularJS this object is called a scope.

What are the directives in AngularJS?

AngularJS directives are extended HTML attributes with the prefix ng- . The ng-app directive initializes an AngularJS application. The ng-init directive initializes application data. The ng-model directive binds the value of HTML controls (input, select, textarea) to application data.

What are the basic directives and controllers in AngularJS explain?

In AngularJS, $scope is the application object (the owner of application variables and functions). The controller creates two properties (variables) in the scope (firstName and lastName). The ng-model directives bind the input fields to the controller properties (firstName and lastName).

How many types of directives are there in AngularJS?

There are two types of AngularJs directives: Built-in directive.


1 Answers

Hmm really hard and not a good thing i think but :

var app = angular.module('MyApp', []);

console.log(app._invokeQueue[0][2][1]);

_invokeQueue is an array if you do that for each entry getting the [0][2][1] you'll see the name of each provider in your module.

If you lok the _invokeQueue alone you'll see a lot of things that you'll like the name of the provider like below but his type too (directive, controller, ...);

But you feel that this is a tricky thing not a good thing a really bad practice but anyway really fun.

Don't use it in production !

like image 113
Thomas Pons Avatar answered Oct 13 '22 18:10

Thomas Pons