0

I have 100 items in a list like this. I would like to know which items of those 100 items is visible on screen, but seem ion-list doesn't provide that method. How can I achieve it?

<ion-list>
  <button ion-item *ngFor="let item of items" (click)="itemSelected(item)">
    {{ item }}
  </button>  
</ion-list>
user38931
  • 471
  • 1
  • 6
  • 16
  • Do these items have a fixed height? If so, you could do some maths based on the scroll position (and the header, and so on...), to calculate which items should be shown in that position... – sebaferreras Jul 27 '17 at 06:48
  • unfortunately it's not fixed height. – user38931 Jul 27 '17 at 09:01
  • Why would you need to know the visible items? Maybe if we know more about what your requirement is, we can find another way to do it – sebaferreras Jul 27 '17 at 09:31

1 Answers1

0

You could try making item an object and then giving it an int index value in the backend typescript...

Try this

<tr *ngFor="#city of cities">
  <template [ngIf]="city.indexValue == '0'">
    <td>{{city.name}}</td>
  </template>
</tr>

In the typescript...

class MyComp {
   selectedCity: Object;
   cities: Object[] = [
      {name: "SF", indexValue: "0"},
      {name: "NYC", indexValue: "1"}
   ];
}