0

I want to get Angular Module name in JavaScript.

Means i want to retrieve module name of angular js application in my javascript file so that i can apply other functionality on that module.

I want to get value of ng-app or data-ng-app

2
  • 1
    how does any of the existing angular code work at all, if you don't know the name of the module? It's not really clear what you are truly asking for here, or why it would be practical. Commented Nov 16, 2016 at 11:48
  • Just query the element that attribute is attached to and get the attribute value. Commented Nov 16, 2016 at 11:49

1 Answer 1

0
app.controller('TestCtrl', ['$scope','$rootElement',
    function($scope, $rootElement) {
        console.log($rootElement.attr('ng-app'));  
    }
]);

DEMO

Sign up to request clarification or add additional context in comments.

3 Comments

No i want to get in other javascript file not in same file where i have define app = angular.module('.........')
@JivaniJaydeep you cannot do that
I'm creating one plugin and in that i want to get user's application module dynamically so i can apply my plugin functionality on that same module..

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.