26
<tr *ngFor="let a of arrayOfObjects">
    <td *ngFor="let item of cfValues | keyvalue">
        {{item.value}}
    </td>
</tr>

I am just trying to print the items in the regular order but the key/value pipe does a default sorting based on the index. Is there a way to disable the default sorting?

Akber Iqbal
  • 14,487
  • 12
  • 48
  • 70
Abdul K Shahid
  • 504
  • 1
  • 4
  • 17

1 Answers1

66

You need to return 0 if you want them to not be ordered. So in your cause you could either do <td *ngFor="let item of cfValues | keyvalue : 0">

But that would throw a ts error: TypeError: The comparison function must be either a function or undefined

Else, you can create a function that returns 0 and use

returnZero() {
    return 0
}

[... in your template]

<td *ngFor="let item of cfValues | keyvalue : returnZero">
Aniket kale
  • 609
  • 7
  • 23
alberto montalesi
  • 978
  • 11
  • 17