Hiện đang làm việc trên ứng dụng TV Angular JS. Ứng dụng nhận dữ liệu từ cuộc gọi api. Tôi đang cố gắng để có được những hình ảnh từ mảng kết quả.AngularJS GET 404 Không tìm thấy
Dưới đây là các mã cho mainController.js
app.controller("mainController", function($scope, $http){
$scope.apiKey = "b3e2e6f87d3aeec3075668a1bd4a78e2";
$scope.init = function(){
//api call requires format, apiKey, date, and days
var today = new Date();
//format apiDate according to the api specifications
var apiDate = today.getFullYear() + ("0" + (today.getMonth()+1)) + today.getDate();
$scope.results = [];
console.log(apiDate);
$http.jsonp('http://api.trakt.tv/calendar/premieres.json/' + $scope.apiKey + '/' + apiDate + '/' + 30 + '/?callback=JSON_CALLBACK').success(function (data){
//connection successful
//console.log(data);
angular.forEach(data, function (value, index){
var date = value.date;//stores the date of the tv shows
angular.forEach(value.episodes, function (tvshow, index){
//this adds the locally store date to the tvshow object
tvshow.date = date;
$scope.results.push(tvshow);
});//end 2nd for each
});//end 1st for each
}).error(function (error){
//connection failed
});
};
});
Dưới đây là các mã cho index.html
<ul class="episode-list">
<li ng-repeat="tvshow in results">
<div class="row-fluid">
<div class="span3">
<img src="{{tvshow.episode.images.screen}}"/>
</div>
</div>
</li>
</ul>
Giao diện điều khiển trả về các lỗi sau đây:
GET: // localhost /tvApp/%7B%7Btvshow.episode.images.screen%7D%7D 404 (Không tìm thấy) localhost /: 29
GET //localhost/tvApp/%7B%7Btvshow.episode.images.screen%7D%7D 404 (Không tìm thấy) angular.min.js: 20
Tôi không hoàn toàn chắc chắn tại sao điều này xảy ra. Bất kỳ trợ giúp sẽ được đánh giá cao. Tôi đã tìm kiếm một vấn đề tương tự nhưng không thành công
Không có gì sai với mã của bạn, có thể liên kết của bạn để nhận $ http không chính xác một cách hợp lý, tất cả mã của bạn là chính xác – Milad