I want something strange for our big angular project. I want to access 
scopes and services by name from devtool console. The simplest solution for 
scopes is select the DOM element and call

> angular.element($0).scope().books

in console. But it is not really usefull. So, I want to write something 
like this:

> booksPageController.books

and don't think about page elements.
Also, I want to access directives by name and get an array of scopes (each 
scope for each usage of directive) something like this:

> bookCard
// -> [$scope, $scope, $scope]
> bookCard[0].title
// -> "Moby Dick"

where bookCard is the name of directive. And then, I want to access 
services by name:

> booksService.getList()

It is important to get the custom services from the project. But $http is 
tasty too.

For now I found a solution for controllers:

(function(original) {
    angular.modules = [];
    angular.module = function() {
        if (arguments.length > 1) angular.modules.push(arguments[0]);
        return original.apply(null, arguments);
    };
})(angular.module);


angular.module('tmp').config(function ($provide) {
    $provide.decorator('$controller', function ($delegate) {
        return function(constructor, locals, later, indent) {
            if (typeof constructor == "string") window.controllers[
constructor] = locals.$scope;
            return $delegate(constructor, locals, later, indent);
        }
    });
})

This hack allow me to get the list of a controllers with their scopes. And 
a list of modules in a angular.modules that contains names of services, 
directives and so on.

Can anybody help my to get scopes for directives and services by names from 
an angular.modules, or decorate something to get it?..

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to