Issue
<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?
Solution
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">
Answered By - alberto montalesi
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.