Question

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);
  });
Was it helpful?

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) {...});
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top