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.
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; });    Anyone please help me how to display data from local JSON file? Thanks in Advance.
factory('webtest', function($q, $timeout, $http) { var Webtest = { fetch: function(callback) { return $timeout(function() { return $http. get('webtest. json') . then(function(response) { return response.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With