如何使用使用本地文件Angular.JS没有服务器调用一个JSON文件 [英] How to call a JSON file using Angular.JS using a local file without a server

查看:125
本文介绍了如何使用使用本地文件Angular.JS没有服务器调用一个JSON文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面是我的控制器code:

Here is my controller code:

angular.module('navApp', []).controller('blogCtrl', function($scope, $http) {
    $http.get("../json/blogs.json").success(function(response) {$scope.blogs = response.blogs;});
});

我如何可以加载blogs.json? Blogs.json包含了两个博客。

How can I load the blogs.json? Blogs.json contains two 'blogs'.

推荐答案

显然铬不允许由于其政策访问本地文件,我是能够运行在Firefox这一请求。

Apparently chrome does not allow local file access due to its policy, I was able to run this request in Firefox.

这篇关于如何使用使用本地文件Angular.JS没有服务器调用一个JSON文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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