如何在AngularCtrl中应用成功并失败
JSONArray arr = jobObject.getJSONArray("MultipleChoices");
答案 0 :(得分:1)
我所理解的是,您正在询问如何处理承诺返回成功/失败,就像您从$ http请求服务获得的那样,所以下面是一个示例:
$http.get('http://freegeoip.net/json')
.success(function (data, status, headers, config) {
//TODO When request Success
console.log(data);
$scope.Employee = data;
})
.error(function (data, status, headers, config) {
//TODO When request Failed
console.log(data); //Server Response values if there's any
$scope.Employee = [];
});
答案 1 :(得分:0)
这是一个可以帮助您的示例代码。
$scope.Btncall = function () {
MyService.GetDatafromApi().success(function (data, status,headers)
{
$scope.Employee = data;
})
.error(function (data, status, headers) {
$scope.Employee = [];
});
}
//Call Btncall Function..
$scope.Btncall();