Angularjs访问本地JSON文件 [英] Angularjs access local json files

查看:378
本文介绍了Angularjs访问本地JSON文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新来angularjs,我已经在网络上一整天一直在寻找,只是为了找到在得到从本地JSON文件中的数据,而不必使用本地主机为我的web应用程序的解决方案。不幸的是,我还没有发现任何。我试着使用$ http.get但我得到跨源*错误。

I am new to angularjs and I've been searching on the web the whole day just to find a solution in getting data from a local json file without having to use a localhost for my webapp. Unfortunately, I haven't found any. I tried using $http.get but I get Cross Origin * error.

难道就没有别的办法,我可以从我的本地JSON文件中的数据,而无需本地托管Web应用我?

Is there no other way that I could get the data from my local json file without having to locally host my webapp?

是否angularjs有任何其它函数来获得从本地JSON文件的数据,而无需使用其$ http.get

Does angularjs have any other function to get data from local json files without having to use its $http.get?

推荐答案

您需要将应用程序部署到一些http服务器,以最简单的方法是使用节点,这里是〔实施例的https://www.npmjs.org/package/http-server ,或者你可以改变你的浏览器安全设置。

You need to deploy your application to some http server, the easiest way to this is using node, here is the exmaple https://www.npmjs.org/package/http-server, or you can change you browser security settings.

这篇关于Angularjs访问本地JSON文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆