angularjs - Using $http with $exceptionHandler -


i want post errors happen inside angular application.

i followed approach given in related question, suggested in answer, injected $injector , got $http service there. line

uncaught error: circular dependency: $http <- $exceptionhandler <- $rootscope

keeps comming.

here fiddle problem

with relevant code:

var mod = angular.module('test', []); mod.config(function ($provide) {     $provide.decorator("$exceptionhandler", ['$delegate', '$injector',             function ($delegate, $injector) {       var $http = $injector.get("$http");     }]);   }); mod.controller('testctrl', function ($scope) {   }); 

if comment line

var $http = $injector.get("$http");

the circular dependency error gone.

i think i'm missing in understanding. doing wrong? after all, seems have worked others.

any suggestion on how achieve initial goal of 'posting errors service' welcomed.

thanks everyone

wrap injector code within function

var mod = angular.module('test', []); mod.config(function ($provide) {     $provide.decorator("$exceptionhandler", ['$delegate', '$injector',function ($delegate, $injector) {            return function (exception, cause) {               var $http = $injector.get("$http");            }     }]);   });    mod.controller('testctrl', function ($scope) {   }); 

Comments

Popular posts from this blog

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -