문제

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