0

I have a array. this list is in order of array[1]. I want to show the list in the current order in Angular.

[[1,8],[7,6],[80,4],[3,4],[12,3],[5,2]]

But Angular breaking the order

1,8
80,4
7,6
5,2
3,4
12,3

My code

<div>
<table>
   <li *ngFor="let item of variablesthree | keyvalue">
       {{item.value[0]}}:{{item.value[1]}}
</table>
</div>

Also, when I examine the page source, I can see that the index comes in order.

1 Answer 1

1

It seemes the order outputs comes because of the pipe you are using. In this https://angular.io/api/common/KeyValuePipe you can see the output is sorted by the key of the elements, so you can remove the pipe or using a custom one to mantain the order.

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.