angular keyvalue pipe sort properties / iterate in order

Discussão em 'Angular' iniciado por danday74, Novembro 22, 2024.

  1. danday74

    danday74 Guest

    When using the Angular keyvalue pipe to iterate over an object's properties as follows:

    <div *ngFor="let item of object | keyvalue">
    {{item.key}}:{{item.value}}
    </div>


    I have experienced an issue where the properties were not iterated in the order expected. And this comment suggests that I am not the only one to experience this issue:

    How to loop over object properties with ngFor in Angular

    Can someone advise what determines the order of iteration when using the keyvalue pipe please and how to force a specific iteration order? My ideal order of iteration is the order in which the properties were added.

    Thanks

    Continue reading...

Compartilhe esta Página