user1098063
user1098063

Reputation:

angular multidimensional array

I have a JSON string passed to angular. One of the array fields has another array, called products. How can I do an angular repeat on those items?

When I just use {{item.products}}, the products print out, but not in a repeat fashion. How can I iterate those products as well?

Here my angular:

function CashTransController($scope, $http)  {

        $scope.items = {[$data]}    
        $scope.mySortFunction = function(item) {
            if(isNaN(item[$scope.sortExpression]))
                return item[$scope.sortExpression];
            return parseInt(item[$scope.sortExpression]);
        }


        $scope.refreshSessionList = function(){


            $http({
                method: 'POST',
                url: 'browser.php?conference_year='+$scope.conference_year,
                headers:{'Content-type' : 'application/x-www-form-urlencoded; charset=UTF-8'}
                });   
        }

}

<tr ng-show="search" ng-repeat="item in items | filter:search">
   <td>{{item.firstname}} {{item.lastname}}</td>
   <td>|</td>
   <td valign="top">{{item.redemption_code}}</td>
   <td>|</td>
   <td>${{item.amount}}</td>    
   <td>|</td>
    <td>{{item.creation_date}}</td>  
    <td>|</td>
    <td>{{item.products}}</td>

    <td><a href="redeem_cash_transaction.php?id={{item.id}}" onClick="return confirm('Are you sure? This action cannot be undone!');">Complete Transaction</a><td>  

</tr>

Upvotes: 0

Views: 253

Answers (1)

hrgui
hrgui

Reputation: 630

When you go to item.products, you can also do another ng-repeat there, e.g.

<td><span ng-repeat="product in item.products">{{product}}</span></td>

Upvotes: 1

Related Questions