2

This is my json. I need to show only the first image in my imageview. i tried with {{p.url}} to get the images. but its not worked fine.

 [{

        "comment": "",
        "adoptId": null,
        "images": [
          {
            "id": 4,
            "name": "3_1.jpg",
            "url": "Content\\RacePictures\\YRMTH-2017-04-15-HT09.jpg"
          },
          {
            "id": 5,
            "name": "3_2.jpg",
            "url": "Content\\RacePictures\\YRMTH-2017-04-15-HT09.jpg"
          }
        ]

HTML

    <div class="" ng-repeat="d in photos">
     <div class="col-md-6" >
    <div ng-repeat="p in d.images">
    <img ng-src="http://localhost:20513/{{p.url}}" />
  </div>

Angular Controller

    var httpRequest = $http({
                method: 'GET',
                url: urls.api + 'Library/treeImages/Filter/' + images,
      }) .success(function (data, status) {
    $scope.photos = angular.fromJson(data);
                            }
)
}
1
  • 1
    try this <img ng-src="http://localhost:20513/{{d.images[0].url}}" /> Commented May 3, 2017 at 4:33

2 Answers 2

2
<div class="" ng-repeat="d in photos">
   <div class="col-md-6" >
       <img ng-src="http://localhost:20513/{{d.images[0].url}}" />
   </div>
</div>

try this

Sign up to request clarification or add additional context in comments.

2 Comments

<div ng-repeat="p in d.images"> with this line it showing the all the images bro. actually we dont need this line.
Updated the answer. :)
1

just remove the ng-repeat and access the image array by the index

<div class="" ng-repeat="d in photos">
     <div class="col-md-6" > 
    <img ng-src="http://localhost:20513/{{d.images[0].url}}" />
 </div>

1 Comment

@Coder no prob machan

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.