Last active
October 27, 2015 16:36
-
-
Save AshCoolman/7b004ee2a33530c2670f to your computer and use it in GitHub Desktop.
Angular 1.x module access from non-angular code (e.g. console, react etc)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var getService = function (serviceName) { | |
return angular.element(document.body).injector().get(serviceName); | |
} | |
var getRootScope = function () { | |
return angular.element(document.body).scope().$root; | |
} | |
var getScope = function (selector) { | |
if (!selector) { | |
return angular.element(document.body).scope().$root; // default rootscope | |
} | |
return angular.element(document.querySelector(selector)).scope(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment