javascript - AngularJS and Edmunds Media API to pull vehicle images -


situation: using rails app, , $http.get in angularjs pull photos edmunds.com media api.

task trying complete: ng-repeat through vehicle photos.

conditions: getting response , able load 1 image, how can have repeat through photos array , images.

apologies unclear explanation, , appreciated.

index.html:

   <h1> wheel tire family </h1>    <!--  car images  -->    <div ng-init="carimages">       <img src="https://media.ed.edmunds-media.com/{{carimages}}">     </div>    

catalog_controller.js:

$scope.photos = {}; $scope.carimages = {};  //get edmunds media api //make model year photos  $http.get("https://api.edmunds.com/api/media/v2/audi/a3/2015/photos?title=&category=exterior&provider=oem&width=1280&shottype=s&pagenum=1&pagesize=10&view=basic&api_key=api_key&fmt=json")     .success(function (data) {         var photos = data;         console.log(photos);         $scope.carimages = photos.photos[0].sources[0].link.href;         console.log($scope.carimages);         }); 

maybe this?

angular

.success(function (data) {     $scope.carimages = data.photos; }); 

html

<div ng-repeat="carimage in carimages">     <img ng-src="https://media.ed.edmunds-media.com/{{carimage.sources[0].link.href}}"> </div> 

this should loop through images , pick first "source" link. recommended use ng-src instead of src.


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -