我想从我本地计算机上的JSON文件中获取数据.但我无法获得数据.它显示$ http的一些跨域错误.
这是我的代码.
angular.module('myApp',[])
  .controller('myCtrl', function ($scope, webtest) {
     webtest.fetch().then(function (data) {
         $scope.accounttype = data;
     })
});
.factory('webtest', function($q, $timeout, $http) {
    var Webtest = {
        fetch: function(callback) {
            return $timeout(function() {
                return $http.get('webtest.json')
                .then(function(response) {
                      return response.data;
                });
            }, 30);
         }
    };
    return Webtest;
}); 
有人请帮我如何显示本地JSON文件中的数据?提前致谢.
小智 37
这很简单
$http.get('phones/phones.json').then(function(response) {
   $scope.phones = response.data;
});
请参阅:http://stackoverflow.com/questions/21589340/read-local-file-in-angularjs