Skip to content

Instantly share code, notes, and snippets.

@calendee
Last active February 15, 2017 17:16
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save calendee/45eb8f0a777613d253de to your computer and use it in GitHub Desktop.
Save calendee/45eb8f0a777613d253de to your computer and use it in GitHub Desktop.
Fire Angular RootScope Event from Console, Get Get An AngularJS service
// Right click an element and select "Inspect Element"
// Courtesy : http://michalostruszka.pl/blog/2013/09/24/angularjs-in-browsers-console/ &
// http://ionicframework.com/blog/angularjs-console/
var scope = angular.element($0).scope();
var rootScope = scope.$root
scope.$apply( function() {
rootScope.$broadcast('showOffline', {msg : 'goes here', duration : 1230});
})
@calendee
Copy link
Author

calendee commented Jan 11, 2015

Getting Scope & RootScope

var app = document.getElementsByClassName('kit');
var scope = angular.element(app[0]).scope();
var rootScope = scope.$root
scope.$apply( function() {
rootScope.$broadcast('showOffline', {msg : 'goes here', duration : 1230});
}) 

Getting A Service

var myService = angular.element(document.querySelector('body')).injector().get('MyService')

@calendee
Copy link
Author

calendee commented Feb 15, 2017

var body = document.getElementsByTagName('body')
var scope = angular.element(body[0]);

scope.$$listenerCount["batch-mode-changed"]
scope.$$listeners

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment