Search code examples
javascriptangularjssplitangularjs-ng-repeat

Angular 1 ng-repeat with filter for split the string values within same json array


I used the ng-repeat to append the json array value ,the problem is pictureURLS object is having the string value of images what I am looking separate the pictureURLS string value' and display the images

javascript

 var results= [
                {
                   "title": Album1,
                   "pictureURLS": "pirul.jpg,picurl2.jpg,picurl3.jpg",
                   "ApprovalStatus": "2",


                },
                {
                   "title": Album2,
                   "pictureURLS": "pirul.jpg,picurl2.jpg,picurl3.jpg",
                   "ApprovalStatus": "2",


                },
                {
                   "title": Album3,
                   "AlbumPictureURLS": null,
"ApprovalStatus": "2",

             ]

HTML

<div ng-repeat="photo in results">
<h4>{{photo.title}}</h4>
<img src="{{photo.pictureURLS}}" />
</div>

Solution

  • Try it like this;

    <img ng-repeat="url in photo.pictureURLS.split(',')" src="{{url}}" />