I do not think that the decision made will work if the array mutates. I find it ideal to create a value converter that returns a return array without changing the original. For instance:
Js
export class App {
message = 'Hello World!';
friends = ['a', 'b', 'c'];
attached() {
//MUTATE!
setTimeout(() => { this.friends.push('d') }, 300);
}
}
export class ReverseValueConverter {
toView(array) {
return array.slice().reverse();
}
}
HTML
<p repeat.for="friend of friends | reverse">Hello, ${friend}!</p>
Execution example: https://gist.run/?id=20d00a205e651b6b4d7064e2f57d2675
, @computedFrom https://github.com/aurelia/binding/issues/249.
- BindingEngine , , .
, !