当我一起构建我的代码时,我得到一个实例化主模块的错误,因为它依赖于下面的模块,这也是一个实例化的错误。据我所知,我正在做一切正确的模块,但我错过了什么?
angular.module('exceptionOverride').config(function($provide) {
$provide.decorator('$exceptionHandler', ['$delegate', '$injector',function($delegate,$injector) {
return function(exception, cause) {
var $rootScope = $injector.get('$rootScope');
var loggerService = $injector.get('loggerService');
$delegate(exception, cause);
exception.message = $rootScope.currentState + ': ' + exception.message;
//send the exception off to the logging service
loggerService.log(exception);
};
}]);
});
如果您认为需要,我可以为其他模块添加代码。
答案 0 :(得分:2)
您还必须执行配置功能:(注意['$provide', function($provide){ ...
)
angular.module('exceptionOverride').config(['$provide', function($provide) {
$provide.decorator('$exceptionHandler', ['$delegate', '$injector',function($delegate,$injector) {
return function(exception, cause) {
var $rootScope = $injector.get('$rootScope');
var loggerService = $injector.get('loggerService');
$delegate(exception, cause);
exception.message = $rootScope.currentState + ': ' + exception.message;
//send the exception off to the logging service
loggerService.log(exception);
};
}]);
}]);