This seems like a trivial thing, but I canβt find it:
What if I want to change the order of my elements in repetition without affecting the order of the array , for example:
<template repeat="{{layer in layers}}">
<div>{{layer.name}}</div>
</template>
where layers is an array of objects.
I tried to apply a filter and then worked with a copy of the array, for example:
<template repeat="{{layer in layers | reverse}}">
<div>{{layer.name}}</div>
</template>
...
reverse: function(arr){
return _(arr).reverse();
}
but this leads to some observers failing as they look at the copy instead of the original objects. I do not want to apply sorting to the original array, since other parts of the code depend on this order.
Does anyone know an option that affects only the display order in the DOM?
source
share