Lorenzo Permalino
Lorenzo Permalino

Reputation: 1

Can you have a dynamic collection for ng-repeat in AngularJS?

I have the ng-repeat directive used in my code, but I want to have the dynamic collection inside the same. It looks like this:

<tr md-row ng-repeat="agentData in verticalAgents.ALLAgents">
    <td md-cell>{{ agentData['username'] }}</td>
</tr>

I was wondering of I could make the ng-repeat look like this:

<ng-repeat="agentData in verticalAgents.{{verticalAgents.Tab}}">

where verticalAgents.Tab is dynamic. I know this is not possible, but what can I do to solve it?

Upvotes: 0

Views: 54

Answers (1)

devqon
devqon

Reputation: 13997

Just use the same notation as you do in agentData['username']:

<tr md-row 
    ng-repeat="agentData in verticalAgents[verticalAgents.Tab]">
    <!-- ... -->
</tr>

Upvotes: 3

Related Questions