Check value with previous value



In a ListView i need to check if a date is different from the date of previous record

< ListView [items]="myItems" (itemTap)="onItemTap($event)" >
< ng-template let-item="item" >

< /ng-template >

< /ListView >

Anyone can help me?

Thank you


You can use an index, passing to a function. And in it you take the previous index (index - 1), and validate with the new indece. Like this :

< ListView [items]="myItems" (itemTap)="onItemTap($event)" >
  < ng-template let-item="item"  let-indx="index">
    <Label [text]="checkDate(indx)"></Label>

  < /ng-template >
< /ListView >
  if(this.myItems[index] != this.myItems[index-1]){


Excuse me, where i’ve tu put the checkdate function?
In which file?

thank you


Are you using angular?


If so, you put it inside the .ts file with the same name as your view, for example:

View: home.component.html

would put the function in the file: home.component.ts