Вопрос

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