无法使用angularjs从json文件中检索数据,我正在尝试从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>
答案 0 :(得分:-1)
收到回复后尝试拨打$ apply。
if(!$scope.$$phase) $scope.$apply();