I am working with Angular version 1.6.1. I have an event object array that is loaded into the dom using ng-repeat. An event has the following properties:
{
city: ""
hash: ""
timestamp: 1234578910
noCount: 1
unknownCount: 2
yesCount: 2
}
As you can see an event has a timestamp. This timestamp is transformed using a filter:
app.filter('dateFilter', [function () {
return function (v) {
let operationDate = new Date(v);
let day = 'Yesterday: ';
if (new Date(v).setHours(0, 0, 0, 0) == new Date().setHours(0, 0, 0, 0)) {
day = 'Today: ';
}
let minutes = operationDate.getMinutes();
return day + operationDate.getHours() + ':' + (minutes < 10 ? "0" : "") + minutes;
};
}
]);
Here my ng-repeat:
<div ng-class="getHighlight(operation.timestamp)" style="margin-top: 10px;">
<div class="row">
<h3 class="col-md-6 col-xs-6">
{{operation.city}}
</h3>
<div class="col-md-6 col-xs-6" style="text-align: right;">
<h3>
{{operation.timestamp | dateFilter}}
</h3>
</div>
</div>
.
.
.
.
</div>
I periodically get Data from an API and update the event-participants if they changed(every 5 seconds). The problem i got is that when a new day begins the filter doesn't update the prefix to: "Yesterday".
Is there a way to re-apply filters OR to force a reload of a specific DOM-Element?