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);
  });
有帮助吗?

解决方案

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) {...});
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top