.factory('Api', function($http) {
var API = "http://127.0.0.1:4567/";
return {
get: function(method) {
return $http.get(API + method).success(function(result) {
return result;
});
}
}
}
Then
console.log(Api.get("MAppData"));
Returns
Object {then: function, success: function, error: function}
为什么不返回结果(响应数据)?
$http
返回一个承诺,你需要链接.then()
获取这样的数据:
Api.get("MAppData").then(function(response){
var data = response.data;
});
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)