斯蒂芬大帝
H5edu教育html5开发 培训为您解答:angularjs $http调用接口的四种方式:1.$http.get("/merchantmall/merchant.json").success(function(data, status, headers, config) {console.log(arguments);}).error(function(data, status, headers, config) {console.log(arguments);})2.$http({url: "/merchantmall/merchant.json",}).success(function(data, status, headers, config) {console.log(arguments);}).error(function(data, status, headers, config) {console.log(arguments);})3.var promise = $http({method: 'GET',url: '/api/users.json'});promise.then(function(resp){// resp是一个响应对象}, function(resp) {// 带有错误信息的resp});4.var promise = $http({method: 'GET',url: '/api/users.json'});promise.success(function(data, status, headers, config){// 处理成功的响应});// 错误处理promise.error(function(data, status, headers, config){// 处理非成功的响应});