Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Angularjs $http in browser console

I've testing AngularJS services in browser console during development for quick verification. The way I inject a service into console is as describe in this question or

var $inj = angular.injector(['myApp']);
var serv = $inj.get('myService');
serv.doSomething();

That was working perfectly with AngularJS 1.0.7. However, after upgrading to 1.1.5, it doesn't work anymore for services that uses $http service, that no xhr will be sent.

I've tested injecting $http directly, it also doesn't work. AngularJS changelog seems to have no record on this issue. May I know what's the problem here?

Update:

It seems like AngularJS 1.0.7 Uncompressed version doesn't work as well. Currently the tested working version is only AngularJS 1.0.7 Minified.

It works for Uncompressed also.

like image 735
PSWai Avatar asked Aug 26 '13 03:08

PSWai


1 Answers

$http = angular.element(document.body).injector().get('$http');

then

$http.get(...) // or post or whatever
like image 127
dustin.schultz Avatar answered Sep 19 '22 09:09

dustin.schultz