I have a JSON file that I want to use in my Angular application. I came across a discussion here suggesting the use of $http.get to load JSON from the filesystem. However, I am encountering an issue where I keep getting a "http://localhost:9000/jsonFile.json not found" error when trying to load the file in the console (via $injector.get). My app structure, generated using Yeoman, is as follows:
app
--scripts
--services
--jsonLoader.js
--app.js
--index.html
--jsonFile.json
The jsonLoader.js file contains:
angular.module('jsonLoader', [])
.service('loader', function($http){
var schema = {};
$http.get('jsonFile.json')
.then(function(res){
schema = res.data;
});
return schema;
});
Despite trying different path combinations to locate the JSON file, I continue to receive a 404 error when accessing the service. Any help on this issue would be greatly appreciated!