写法1
$http({ method: "GET", url: ‘data.json‘, }).success(function(data, status, headers, config){ $scope.list = data; }).error(function(data, status, headers, config) { // });
var promise = $http({ method: "GET", url: ‘data.json‘, }) promise .success(function(data, status, headers, config){ // $scope.list = data; }) .error(function(data, status, headers, config) { // });
$http({ method: "GET", url: ‘data.json‘ }) .then(successCallback, errorCallback);
function successCallback(responseObj){ //相应对象变了,不是data, status, headers, config而是包含他们四个属性的完整对象 $scope.list = responseObj.data } function errorCallback(){ }
$http.get(‘data.json‘).success(function(data){ $scope.list = data })
实例:demo
原文:http://www.cnblogs.com/mafeifan/p/5039798.html