無法使用angularjs,我正在嘗試從JSON文件中的數據,這裏是我的代碼無法使用angularjs來從JSON文件數據
<!DOCTYPE html>
<html>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>
<body>
<div ng-app="myApp" ng-controller="customersCtrl">
<ul>
<li ng-repeat="x in names">
{{ x.eng_rev_type + ', ' + x.year_end }}
</li>
</ul>
</div>
<script>
var app = angular.module('myApp', []);
app.controller('customersCtrl', function($scope, $http) {
$http.get("http://preview.sokrati.com/data/open_spendings.json")
.success(function (response) {$scope.names = response.data;});
});
</script>
</body>
</html>
當你運行你的代碼時會發生什麼?你到底想要發生什麼?錯誤是什麼? – LionC
數據不會從json文件中檢索 – ch3t
嘗試'$ http.get(「http://preview.sokrati.com/data/open_spendings.json」).then(function(response){$ scope.names = response。數據;});});' – DonJuwe