Maintain ngRepeat order while bound data changes

158 Views Asked by At

I am new to Angular and I am now learning about directives.

I have created a directive that will create a table.
You can sort the table by clicking on the header arrows.
You can also edit/delete a row by clicking on the action button.

Table at default order

The problem with my table is that when the rows are sorted by some column, and I edit an item under that column, the table resorts because of the changed data. Thus my currently editting item moves to another row and the current input fields contain a different one.

For example, if I sorted the table by visits, and then I edit a visit data in a row,

Table at editting state changes to : Table resorts when bound data changes

How can I maintain the current order of the rows during edit, and only allow resort when I click on the apply button (check) ?

1

There are 1 best solutions below

0
On

You can copy the model which will be edited during editing. And in your save function, update the actual model in table list.