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.
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
Post a Comment