SavantMohan
SavantMohan

Reputation: 35

nested ng-repeat in angular js

repeat inside ng-repeat.

<li ng-repeat="(key,value) in OauthSwaggerData.paths " > 
    <div class="col col-100">{{key}}</div>   
    <div ng-repeat="APIDetails in OauthSwaggerData.paths['/key']">
        <div class="col col-100"><h4>Summary</h4> </div>
        <div class="col col-100">{{APIDetails.summary}}</div>
        <div class="col col-100"><h4>Description</h4> </div>
        <div class="col col-100">{{APIDetails.description}}</div>
        <div class="col col-100"><h4>Parameters</h4> </div> 
    </div>
</li>

In the first line i want to display the keys which are available , which is working fine. In the second ng-repeat I want to pass the name of the key which i have selected. e.g.

<div ng-repeat="APIDetails in OauthSwaggerData.paths['/token']"> . 

When i hardcode this value i am getting the desired output. But i want to pass the "key " from the first loop in this second loop.

<div ng-repeat="APIDetails in OauthSwaggerData.paths['/key']"> 

which i not working fine.

Kindly help me to resolve the issue.

Upvotes: 0

Views: 50

Answers (2)

Van Nguyen
Van Nguyen

Reputation: 76

hope this help

<li ng-repeat="(key,value) in OauthSwaggerData.paths " > 
<div class="col col-100">{{key}}</div>   
<div ng-repeat="APIDetails in value">
    <div class="col col-100"><h4>Summary</h4> </div>
    <div class="col col-100">{{APIDetails.summary}}</div>
    <div class="col col-100"><h4>Description</h4> </div>
    <div class="col col-100">{{APIDetails.description}}</div>
    <div class="col col-100"><h4>Parameters</h4> </div> 
</div>

Upvotes: 0

arg20
arg20

Reputation: 4991

In your third line try:

<div ng-repeat="APIDetails in OauthSwaggerData.paths['/' + key]">

Upvotes: 2

Related Questions