I use Angular 4.4.6 in my project. Having a list of events I want this list to be sorted by date. I achieved this by adding ng2-order-pipe
// customers.html
<tr *ngFor="let event of customer.events | orderBy: order : reverse">
The sorting works but my problem is that if I add an event, it is placed at the end of the list, ignoring sorting.
// customers.ts
this.order = 'date';
this.reverse = true;
.........................................
addEvent(new_date, new_state, new_description) {
var new_event = {
date: new_date,
state: new_state,
description: new_description,
customer_id: this.customer['id']
};
this.customer['events'].push(new_event);
}
How to add an event so that it appears in its place according to sorting?