$ http.get不加载JSON [英] $http.get doesn't load JSON
本文介绍了$ http.get不加载JSON的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我无法载入我的 JSON
文件。没有错误。我卡住了,有什么建议?
I can't load my JSON
file. There is no error. I'm stuck, any suggestions?
app.js:
app.controller('StoreController',['$http','$scope', function($http,$scope) {
$http.get("data.json").success(function(response) {
$scope.names = response;
});
}]);
index.html的
index.html
<html ng-app= "App">
<head>
<link rel="stylesheet" type="text/css" href="bootstrap.min.css" />
<script type="text/javascript" src="angular.min.js"></script>
<script type="text/javascript" src="app.js"></script>
</head>
<body ng-controller="MyController">
<div ng-repeat="item in names" style="border: solid 1px black; margin: 10px auto; padding: 5px; width: 500px;" >
<h3>{{item.Name}} </h3>
<p>{{item.Country}}</p>
</div>
</body>
</html>
什么也不显示。我应该怎么办?
Nothing is showing. What should I do?
推荐答案
您必须在本地主机根directory.like运行 XAMPP / htdosc /路径/要/你/文件
并运行程序存在。
You have to run it on the localhost root directory.like xampp/htdosc/path/to/your/file
and run your program there.
这篇关于$ http.get不加载JSON的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文