Narek Mamikonyan Narek Mamikonyan - 1 year ago 79
AngularJS Question

Use Angular constant outside of angular

I know it is not a good practice to use Angular services outside of angular but nevertheless it's very interesting for me, for example I have


how can I retrieve APIprefix value outside of angular scope? For instance from other js file which is not in angular scope.

Answer Source

You can access any service like this:


Note that you should pass to angular.element DOM node where you put ng-app. In the example above document.documentElement is HTML tag.


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download