我想处理错误服务,现在我想手动将单个错误放入服务中,我想使其自动执行。
'use strict';
angular.module('nexoolApp.errorservice', ['nexoolApp.config'])
.service('Errorservices',['nexoolConfig', function (nexoolConfig) {
//console.log('Inside Errorservices');
var showmessage=nexoolConfig.defaultErrorMessage;
this.geterrordetails = function(data)
{
if(data.errors) {
if (data.errors.USER_NOT_PROVIDED) {
showmessage = data.errors.USER_NOT_PROVIDED.message;
} else if (data.errors.ADMIN_NOT_PROVIDED) {
showmessage = data.errors.ADMIN_NOT_PROVIDED.message;
}
}
return showmessage;
};
}]);
最佳答案
假设您已经描述了这种情况:
'use strict';
angular.module('nexoolApp.errorservice', ['nexoolApp.config'])
.service('Errorservices',['nexoolConfig', function (nexoolConfig) {
//console.log('Inside Errorservices');
var showmessage=nexoolConfig.defaultErrorMessage;
this.geterrordetails = function(data)
{
if(data.errors) {
for ( var property in data.errors ) {
showmessage = data.errors[property]['message'];
break;
}
}
return showmessage;
};
}]);
关于javascript - 我想处理错误服务,现在我想手动将单个错误放入服务中,我想自动进行处理,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/54489946/