Can you please tell me how to get inline or embedded JSON file?
Error:
polyfills.js:3 GET http://localhost:8100/data/questions.json 404 (Not Found)
Folder path:
survey-data.ts
@Injectable()
export class SurveyData {
constructor(public http: Http) {
}
getJson(): Observable<any> {
return this.http.get("data/questions.json") //not working here
.map(this.extractData)
.catch(this.handleError);
}
}
questions.json
{
"28903218": {
"type": "group",
"prompt": "Cool, thanks! Now tell us about your child's day:",
"description": ""
},
}
Put the data folder in the www folder. The reason it works is because the www folder is like the root of the "server". This is where static content is served from at runtime. Out of verything else in the src folder, only the assets folder is added to the www folder and the .ts files are compiled to a single entry point file and added to the www/build. In your case data does not get transferred. You can check the contents when you build.