[英]$http.get doesn't load JSON
我無法加載JSON
文件。 沒有錯誤。 我被卡住了,有什么建議嗎?
app.js:
app.controller('StoreController',['$http','$scope', function($http,$scope) {
$http.get("data.json").success(function(response) {
$scope.names = response;
});
}]);
的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>
什么都沒顯示。 我該怎么辦?
您是否在app.js中注冊了模塊應用程序?
var app = angular.module('App',[]);
您必須在localhost根目錄上運行它,例如xampp/htdosc/path/to/your/file
然后在其中運行程序。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.