Search code examples
angularjsdeveloper-tools

How can I access my angular resource from the developer console?


I have this resource:

angular.module('showboardApp')
  .factory('Session', function () {
    return $resource('/api/session.json');
  });

I would like to access it from the chrome developer console. Is there some way to inject it and run immediately with similar syntax to this?

angular.module('showboardApp')
  .run(function(Session){
    var promise = Post.query();
    console.log(promise);
  });

Solution

  • What you basically need is your app's injector. Then you can use it to inject your service to a function and execute some code with it. E.g.:

    var inj = angular.injector(['showboardApp']);
    inj.invoke(function (Session) {...});