Created
September 26, 2018 09:45
-
-
Save tonyjoanes/6f5b96d077385d0cb26c7315f155a5f6 to your computer and use it in GitHub Desktop.
Chrome Snippets for AngularJS
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
/** | |
* Setup the angular injector so we can get instances | |
* of angular objects | |
* Usage: injector.get('dataContext'); | |
*/ | |
var injector = angular | |
.element(document.body) | |
.injector(); | |
/** | |
* Run the NgStat bookmarklet so we can track watchers and | |
* digest cycle runs and average times take | |
* Usage: runNgStat | |
*/ | |
var runNgStat = function() { | |
javascript: (function() { | |
var a = document.createElement("script"); | |
a.src = "https://rawgit.com/kentcdodds/ng-stats/master/dist/ng-stats.js"; | |
a.onload = function() { | |
window.showAngularStats() | |
}; | |
document.head.appendChild(a)})(); | |
} | |
/** | |
* Get the scope being used within an element | |
* if none supplied it will just default to 'applicationHost' | |
*/ | |
var getScopeByElementId = function(elementId) { | |
elementId = typeof elementId === 'undefined' | |
? 'applicationHost' | |
: elementId; | |
return angular.element(document.getElementById(elementId)).scope(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Run the snippet as a Chrome browser snippet and then you have access to the functions it creates