Uiupdates
Uiupdates

Reputation: 196

Nested ng-repeat with same key have different values

Hi am stuck somewhere in my code below image shows my response data I receive from Api.

enter image description here

this is my code I want to make a nested ng-repeat for my Genre but am getting error of

<div class="col-3" id="umovies" ng-repeat="movies in sectionInTheaterMovieProduct" lightgallery>
                <figure class="box movie-bx">
                    <div class="prod-img">
                        <a href="{{movies.HypCat_Name}}">
                            <img ng-src="{{movies.Image}}" alt="{{movies.cat_name}}"/>
                        </a>    
                    </div>      
                    <figcaption>
                        <div class=""><a href="{{movies.HypCat_Name}}">{{movies.cat_name}}</a></div>
                        <p class="notify">{{movies.Parent2Name}}</p>
                        <p class="notify movie-ty"><span ng-repeat="(key,value) in movies.Genre">{{Key}} : {{value}}</span></p>
                        <div class="review-rating">
                            <div class="avg-star">{{movies.Rating}}&nbsp;<span class="icon-rating unrated-star"></span></div>
                            <div class="recommendation">
                                <span class="icon-like"></span><span>{{movies.Recommendation}}%</span>
                            </div>
                            <div class="reviews-cnt">
                                <a class="small" href="{{movies.HypCat_Name}}">{{movies.ReviewCount}}&nbsp;{{movies.ReviewCount == 1 ? 'Review' : 'Reviews'}}</a>
                            </div>

                        </div>
                    </figcaption>
                </figure>   
            </div>

enter image description here

can anyone help me please I need output shown in below image

enter image description here

Upvotes: 0

Views: 141

Answers (1)

Sajeetharan
Sajeetharan

Reputation: 222582

Use track by index to avoid duplicates error, since movies.Genre is a comma separated string

<span ng-repeat="(key,value) in movies.Genre.split(',') track by $index"

since movies.Genre is a comma separated string, you can use .split(',') to make it array.

Upvotes: 1

Related Questions