2

I have an array of objects. I want to display two object per row. Something like:

<div class="row" ng-repeat="twoObject in objects>
    <div class="col-sm-6">{{twoObject(1).name}}</div>
    <div class="col-sm-6">{{twoObject(2).name}}</div>
</div>

As you know here {{towObject(1)}} is not valid code.

How can I achieve this in angularJS?

Imran
  • 4,582
  • 2
  • 18
  • 37

1 Answers1

1

I have fixed this issue using the following trick:

<div ng-repeat="object in objects">
    <div class="row" ng-if="$even">
        <div class="col col-6">{{object[$index]}}</div>
        <div class="col col-6">{{object[$index + 1]}}</div>
    </div>
</div>

This is where I got it: Create Row every after 2 item in Angular ng-repeat - Ionic Grid

Community
  • 1
  • 1
Imran
  • 4,582
  • 2
  • 18
  • 37