I am passing a boolean function in ngIf attribute instead of boolean condition in html template file. But that boolean function is repeating itself based on amount of data in variable messages. If messages have 2 objects than value of ctr in console is increasing from 1 to 69 approx instead of just 1 or 2. What could be the reason for it and how to avoid it while passing function in ngIf attribute?
HTML
<ion-row *ngFor="let message of messages; let i = index; trackBy:trackByMsgId">
<ion-badge *ngIf="isNewDate(i)" color="primary" class="ion-margin">{{message.time | date: 'longDate'}}</ion-badge>
</ion-row>
TS
let ctr = 0;
isNewDate(i) {
this.ctr += 1;
console.log('ctr: ', this.ctr);
return true;
}