2
私は角度のあるアプリケーションがあります。これにはn個のコントローラがあります。私は$ exceptionHandlerについて知っています。これは、カスタムの例外ハンドラです。コントローラangularjsで例外を処理する方法
app.controller('cust1Controller',function($scope,$exceptionHandler)
{
//ajax request or anything
}
app.controller('cust2Controller',function($scope,$exceptionHandler)
{
//ajax request or anything
}
任意の例外は、コントローラのいずれかで発生した場合
'use strict';
angular.module('exceptionHandlingApp')
.config(function($provide) {
$provide.decorator('$exceptionHandler', ['$log', '$delegate',
function($log, $delegate) {
return function(exception, cause) {
$log.debug('Default exception handler.');
$delegate(exception, cause);
};
}
]);
});
は、どのように私は私のカスタムハンドラを呼び出すのですか?
任意のコントローラに「throw 'error''」と書いてください。カスタムハンドラには行きませんか? –
A [デモはこちら](http://jsfiddle.net/stever/pypdm/); –
@ YinGang、それは私が知っている。 throw文を使用して手動でエラーをスローしています。 –