Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Slice Pipe with variable parameters in *ngFor

Tags:

Using the Angular2 pipe slice I can do something like this to only show the first five elements of my items.

<ion-item *ngFor='let item of items | slice:0:5"> 

How can I use variables instead of hardcoding 0 and 5? I want to do something like this and define start and end in my *.ts file.

<ion-item *ngFor='let item of items | slice:"start":"end"'> 
like image 997
Jane Dawson Avatar asked Jul 06 '17 09:07

Jane Dawson


1 Answers

Just remove "(double quotes) from the start and end variable

<ion-item *ngFor='let item of items | slice:start:end'> 
like image 82
Pankaj Parkar Avatar answered Sep 28 '22 08:09

Pankaj Parkar