//显示电影列表100
<!DOCTYPE html>
<html lang="en">
<head>
<title>Movie search App</title>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.6/angular.min.js"></script>
<script type="text/javascript" src="controller.js"></script>
</head>
<body ng-app="myApp">
<div ng-controller="movies">
<ul>
<h1>IMDB 100 Movies</h1>
<li ng-repeat="movie in movies">
{{ movie.title }}
</li>
</ul>
enter code here
</div>
</body>
</html>
// json file
{
"records":
[
{
"title": "The Shawshank Redemption",
"rank": "1",
"id": "tt0111161"
},
{
"title": "The Godfather",
"rank": "2",
"id": "tt0068646"
},
// controller.js
var app=angular.module('myApp',[]);
app.controller('movies', function ($scope,$http) {
$http.get('localhost/SPA/movies.json');
.success(function(responce))
{
$scope.movies=responce.records;
}
});
答案 0 :(得分:3)
从此行中删除;
:
$http.get('localhost/SPA/movies.json');
答案 1 :(得分:0)
将您的controller.js
更改为:
var app=angular.module('myApp',[]);
app.controller('movies', function ($scope,$http) {
$http.get('localhost/SPA/movies.json').success(function(responce) {
$scope.movies=responce.records;
});