Fetching data from local JSON File in angularjs

后端 未结 3 1965
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-25 13:41

I want to fetch data from JSON file which is on my local machine. But I am not able to get the data. It is showing some cross domain error for $http.

Here is my code

3条回答
  •  我在风中等你
    2020-12-25 14:06

    It's very simple like

    $http.get('phones/phones.json').then(function(response) {
       $scope.phones = response.data;
    });
    

    Refer:http://stackoverflow.com/questions/21589340/read-local-file-in-angularjs

提交回复
热议问题