//我们使用Ajax访问本地或者同域名下的数据或者文件
module.controller(‘InTheatersController‘,[‘$scope‘,‘$http‘, function($scope,$http){ $scope.subjects = []; $scope.message = ‘‘; //使用$http服务进行异步请求(同域名下ajax) $http.get(‘./data.json‘).then(function(res){ console.log(res); if(res.status === 200){ $scope.subjects = res.data.subjects; }else{ $scope.message = ‘哎呀,获取数据失败了!‘+res.statusText; } },function(err){ $scope.message = ‘哎呀,获取数据失败了2!‘+err.statusText; }) }]);
原文:http://www.cnblogs.com/beyonded/p/6234942.html