1

I'm creating a table, it works fine when I display data, this is the code

<tr ng-repeat="value in sd.data track by $index | orderBy: syscode">
  <td>{{($index>0 && sd.data[$index].syscode === sd.data[$index-1].syscode) ? '' : value.syscode}}</td>
  <td>{{value.out_signal_id}}</td>
  <td class="text-center no-wrapping">{{value.sig_epoch_utc}}</td>
  <td class="text-center ">{{value.num_of_signals}}</td>
  <td class="text-center no-wrapping">{{value.status_code}}</td>
  <td class="text-center no-wrapping">{{value.status_note}}</td>


 <tr >

My issue is that when I use 'orderBy:' as a filter, I get this error

`Error: [orderBy:notarray] Expected array` but received: 0

I am not sure why, I have checked other questions similar to this, but those didn't answer my question. Any feedback will be appreciated thanks

2 Answers 2

3

Track by should be always at the end and you miss apices so this:

<tr ng-repeat="value in sd.data track by $index | orderBy: syscode">

should be:

<tr ng-repeat="value in sd.data | orderBy: 'syscode' track by $index">
Sign up to request clarification or add additional context in comments.

1 Comment

sorry updating I didn't see the track by
1

This exact scenario is covered in the docs for ngRepeat (see the note at the bottom of the section). Basically, the track by needs to be the last thing in your expression.

value in sd.data | orderBy: 'syscode' track by $index

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.