Using Slice Pipe with Variable Parameters in * ngFor

Using Angular2 pipe slice

I can do something like this to only display 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

it end

in my * .ts file as well.

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

      

+3


source to share


1 answer


Just remove "

(double quotes) from the variable start

andend



<ion-item *ngFor='let item of items | slice:start:end'>

      

+4


source







All Articles