結果頁面是空的,不顯示任何數據
js文件包含:
var Movies = angular.module('Movies', []);
Movies.controller('MoviesController',['$scope', '$http', function
($scope, $http) {
$http.get('http://localhost:19290/CinemaAngularJs/JS/data.json')
.success(function (data) {
$scope.Movies = data.Movs;
})
.error(function (data) {
alert("Error occur");
});
}]);
Data.json文件包含:
"Movs":[
{
"name":"Mision Impossible",
"img":"mi",
"year":"2012",
"short":"Mision Impossible 2012 Mision Impossible 2012Mision Impossible
2012 Mision Impossible 2012",
"description":"Mision Impossible 2012 Mision Impossible 2012Mision
},
{
.............
}]
HTML文件包含:
<html xmlns="http://www.w3.org/1999/xhtml" ng-app="Movies">
<head runat="server">
<title></title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/2.0.0-beta.1/angular2.min.js"></script>
<script src="angular.min.js"></script>
<script src="JS/controller.js"></script>
</head>
<body>
<form id="form1" runat="server">
<div ng-controller="MoviesController">
<ul class="large-block-grid-4 small-block-grid-2">
<li ng-repeat="mov in Movies">
<h2>name : {{mov.name}}</h2>
<img ng-src="Img/{{mov.img}}.jpg" alt="Image Here" />
<h3>year : {{mov.year}}</h3>
<h3>year : {{mov.short}}</h3>
<h3>year : {{mov.description}}</h3>
</li>
</ul>
</div>
</form>
</body>
</html>
什麼是Err或代碼? 我該怎麼做才能運行代碼?
在你的問題中帶一點*自豪感。清理它,我們會提供幫助。 – Nix
代碼沒有什麼問題(但是我在1.4和2.0版本中運行它)http://jsfiddle.net/ncapito/zsj835mc/2/我建議你看看你的數據並確保它返回正確。 – Nix