Angular 显示顺序错误
Angular shows wrong ordered sequence
我有一个数组。此列表按数组 [1] 的顺序排列。我想在 Angular.
中以当前顺序显示列表
[[1,8],[7,6],[80,4],[3,4],[12,3],[5,2]]
但是Angular破坏了秩序
1,8
80,4
7,6
5,2
3,4
12,3
我的代码
<div>
<table>
<li *ngFor="let item of variablesthree | keyvalue">
{{item.value[0]}}:{{item.value[1]}}
</table>
</div>
此外,当我检查页面源代码时,我可以看到索引是按顺序排列的。
订单输出似乎是因为您使用的管道。在此 https://angular.io/api/common/KeyValuePipe 中,您可以看到输出是按元素的键排序的,因此您可以删除管道或使用自定义管道来维护顺序。
我有一个数组。此列表按数组 [1] 的顺序排列。我想在 Angular.
中以当前顺序显示列表[[1,8],[7,6],[80,4],[3,4],[12,3],[5,2]]
但是Angular破坏了秩序
1,8
80,4
7,6
5,2
3,4
12,3
我的代码
<div>
<table>
<li *ngFor="let item of variablesthree | keyvalue">
{{item.value[0]}}:{{item.value[1]}}
</table>
</div>
此外,当我检查页面源代码时,我可以看到索引是按顺序排列的。
订单输出似乎是因为您使用的管道。在此 https://angular.io/api/common/KeyValuePipe 中,您可以看到输出是按元素的键排序的,因此您可以删除管道或使用自定义管道来维护顺序。