i trying loop through returned json , display images based on results. able pull feed, not sure i'm going wrong on grabbing poster_path results , appending <img ng-src=""> path.
the json:
results: [ { poster_path: "/title-of-image.jpg", overview: "description of movie", release_date: "2016-08-03", id: 297761, original_language: "en", title: "movie title", popularity: 44.788935, } } i'm looping through object , able view results in console, can't grab data correctly:
var myapp = angular.module('myapp', []); myapp.controller('democontroller', function($scope, $http){ $http.get("http://api.themoviedb.org/3/movie/now_playing?api_key=ebea8cfca72fdff8d2624ad7bbf78e4c") .success(function(response) { console.log(response); $scope.results = response; }); }); <div class="container" ng-repeat="result in results"> <div class="col-lg-12"> <img class="col-lg-3 col-md-4 col-xs-12 thumbnail" ng-src="http://image.tmdb.org/t/p/w342" + {{result.poster_path}}></a> </div> </div> this i'm seeing in console:
object {page: 1, results: array[20], dates: object, total_pages: 33, total_results: 654}
get http://image.tmdb.org/t/p/w342 400 (bad request)
if @ output of console.log(response), see data want in property called results.
{page: 1, results: array[20], dates: object, total_pages: 33, total_results: 654} so data want response.results. make sense? in mind, want have following html snippet.
<div class="container" ng-repeat="items in results"> <img ng-src="http://www.source-to-image" + {{items.poster_path}}> </div> and following controller:
var movieapp = angular.module('movieapp', []); myapp.controller('moviecontroller', function($scope, $http){ $http.get("http://www.url-to-source") .success(function(response) { console.log(response); $scope.results = response.results; }); }); i can't tell what's in each poster_path, let me know if works.

Comments
Post a Comment