1

I'd like to reference the next element is this possible within the ng-repeat directive ?

 <li ng-repeat="row in rows">
      if {{row.someValue}} === {{row+1.someValue}}
      //Is it poss to check if the following row so I can do some kind of conditional comparison ?
 </li>

Thanks W

2
  • 4
    {{ row.someValue === rows[$index+1].someValue ? 'do something' : 'something else'}} Commented Oct 27, 2014 at 19:16
  • 2
    Why is it now Im thinking of a pumpkin spiced latte : ? Commented Oct 27, 2014 at 19:17

1 Answer 1

1

As @PSL said - you just need to get the next index in the array you are looping:

 <li ng-repeat="row in rows">
          {{rows[$index+1]}} // this will give you the next row's data
    <div ng-switch on="rows[$index+1].value">
        <div ng-switch-when="true">
            <!-- shows when the value of the next row is true-->
        </div>
    <div ng-switch-when="false">
            <!-- shows when the value of the next row is false-->
        </div>
    </div>   
 </li>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.