如何捕获所有异常angularjs 同样
window.onerror = function myErrorHandler(errorMsg, url, lineNumber) {
alert("Error occured: " + errorMsg);//or any message
return false;
}
答案 0 :(得分:0)
将以下代码块放入配置中。您将在此处捕获所有angularjs错误。
$provide.decorator("$exceptionHandler", ["$delegate", "$window", function ($delegate, $window) {
return function (exception, cause) {
$delegate(exception, cause);
};
}]);