Skip to content

Instantly share code, notes, and snippets.

@justinobney
Last active April 15, 2021 16:29
Show Gist options
  • Save justinobney/5629777 to your computer and use it in GitHub Desktop.
Save justinobney/5629777 to your computer and use it in GitHub Desktop.
Get a reference to some angular service in the console
// Get the injector
var injector = angular.element($0/*'[data-ng-app], [ng-app]'*/).injector();
// Get the service
var Service = injector.get('Service');
// Use it!
// Service.addNotification('Some Notification', 'info');
@ajoslin
Copy link

ajoslin commented Jun 3, 2013

You might want to add an angular.element(document).scope().$apply() after adding the notification :-)

@mota57
Copy link

mota57 commented Sep 16, 2017

how can you do this in angular 4?

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