How to extract only 1 image from Json?

0

Hello, I need to extract only 1 image of this Json. Here is my angled code to pull the records from api via get.

    var app = angular.module('myApp', []);
    app.controller('carrosCtrl', function($scope, $http) {
       $http.get("http://www.folhacar.com.br/api/listAnuncios?revenda_id=528&cnpj=13733235000134").success(function(data) { 
        $scope.nomes = data;
      });
    });

The field in this api is "images": ["image01", "image02", "image03"]

    
asked by anonymous 13.07.2015 / 17:03

2 answers

1

I would say that a simple data[N] (where N is a number) will remove the part you need. Either this or data.imagens[N] . But as I do not know how the server is responding to this query (aka we do not see the backend code) it's a bit "windy" I say this.

Can you show us how the backend responds to this response?

    
13.07.2015 / 17:14
0

To get the first image is simple like this:

var img = $scope.nomes.imagens[0];
console.log(img);

Example: link

    
13.07.2015 / 17:21