0
$scope.items = [];
$scope.items.push(items);
<div ng-repeat="item in items">
    <div ng-repeat="(key, value) in item">
        {{value.ItemId}}
    </div>
</div>

How to avoid nested ng-repeat when iterating through an array of objects/arrays?

5
  • In the second line, is items another array of items? Commented May 5, 2014 at 12:27
  • yes, items is array of objects. Commented May 5, 2014 at 12:50
  • why are you adding items again to items? Commented May 5, 2014 at 12:50
  • I'm assigning scope variable with array that I get from server. Commented May 5, 2014 at 12:52
  • I'm pushing new array into scope variable that is type of array Commented May 5, 2014 at 12:54

2 Answers 2

1

You shouldn't push one array into another, use angular.extend

$scope.items = [];
angular.extend($scope.items, items);


<div ng-repeat="(key, item) in items">
    {{item.ItemId}}
</div>
Sign up to request clarification or add additional context in comments.

Comments

0

Why don't you use $resource to get your items from the server?

$resource returns a promise that can be assigned to your scope and will be populated with the data by Angular automatically.

var Items = $resource('/yourUrl');

$resource docs

After you implement your ajax call as a resource, you can simply do $scope.items = Items.query().

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.