[英]Unable to load the config file in angular 2
I have folder structure like below. 我有如下的文件夹结构。
src
app
resources
config
home.json
services
service.ts
I am trying to call the json file from config folder from service.ts like below 我正在尝试从service.ts的config文件夹中调用json文件,如下所示
return this._http.get('../../resources/config/home.json')
And I tried with couple more types. 我尝试了几种其他类型。 Unable to load the json file.
无法加载json文件。
http://localhost:4200/resources/config/homeConfig.json 404 (Not Found) getting this error http:// localhost:4200 / resources / config / homeConfig.json 404(未找到)出现此错误
if your using angular CLI than place inside 如果您使用角度CLI而不是放在里面
src/assets/home.json
src / assets / home.json
access like this 像这样访问
this.http.get('/assets/home.json')
.subscribe(res => this.data = res.json());
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.