0
我见过类似的回复,但没有解决我的问题。在html/JS中完成新手。未载入HTML的JSON文件内容
JSON文件,托管在远程Web服务器:
[
{"firstName": "John", "lastName": "Doe"},
{"firstName": "Anna", "lastName": "Smith"},
{"firstName": "Peter", "lastName": "Jones"}
]
这里是我的JS代码。 $http.get
是一个网站,可让您将JSON数据存储到临时网络服务器中。
automate.js:
var parsefile = angular.module("parser", []);
parsefile.controller("parserCtrl", function($scope, $http) {
$http.get("https://api.myjson.com/bins/wpkh").then(function(response) {
$scope.stuff = response.data;
});
});
和我的HTML代码的部分是:
<div ng-app="parser" ng-controller="parserCtrl">
<ul>
<li ng-repeat="x in stuff">
{{ stuff.firstName }}
</li>
</ul>
</div>
<script src="automate.js"></script>
但是当我运行它,打印的唯一事情是从字面上{{stuff.firstName}}
。
任何提示?
最愚蠢的错误。我想所有程序员都会遇到这种情况......感谢新鲜的眼睛! – ellusion