Using Slice Pipe with variable parameters in *ngFor

浪子不回头ぞ 提交于 2020-08-04 03:43:08

问题


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"'>

回答1:


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

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


来源:https://stackoverflow.com/questions/44944570/using-slice-pipe-with-variable-parameters-in-ngfor

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!