捕获所有异常angularjs

时间:2015-08-23 16:04:11

标签: javascript angularjs

如何捕获所有异常angularjs 同样

window.onerror = function myErrorHandler(errorMsg, url, lineNumber) {
    alert("Error occured: " + errorMsg);//or any message
    return false;
}

1 个答案:

答案 0 :(得分:0)

将以下代码块放入配置中。您将在此处捕获所有angularjs错误。

   $provide.decorator("$exceptionHandler", ["$delegate", "$window", function ($delegate, $window) {
         return function (exception, cause) {
             $delegate(exception, cause);
         };
     }]);