Is there a standard way of showing error messages on ionic mobile app. From the documentation I couldn't find any information associated with showing error messages.
Doc referred: http://ionicframework.com/docs/components/
答案 0 :(得分:0)
Consider you want to send all HTTP errors to Modal you can override exceptions by using $provide decorator "$exceptionHandler"
:
$provide.decorator("$exceptionHandler", function($delegate, $injector) {
return function(exception, cause) {
/* here you can do what u want */
});
To send to native code or even to Crashlytics (reporting server) use Cordova bridge:
app.config(function($provide) {
$provide.decorator("$exceptionHandler", function($delegate, $injector) {
return function(exception, cause) {
if (false) { //(appState !== "...") { // We want to only send the error in this case
$delegate(exception, cause);
} else {
//appState == null;
var MyCordovaService = $injector.get("MyCordovaService");
console.debug({reason: exception, message: exception.message, stack: exception.stack});
var data = {
message: "Exception: " + exception.message,
stack: exception.stack || "none"
};
MyCordovaService.reportClientError(data).then(function(data) {
console.debug('reportClientError success', data);
}, function(error) {
console.debug('reportClientError fail!', error);
});
//}
// Call The original Angular Exception Handler
$delegate(exception, cause);
}
};
});
});
Demo in Codepan
Hope it will help,