在* ngFor中使用带有可变参数的Slice Pipe [英] Using Slice Pipe with variable parameters in *ngFor
本文介绍了在* ngFor中使用带有可变参数的Slice Pipe的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
使用Angular2管道slice
,我可以做这样的事情,以仅显示items
的前五个元素.
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">
如何使用变量而不是对0和5进行硬编码?我想做这样的事情,并在我的* .ts文件中定义start
和end
.
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"'>
推荐答案
只需从start
和end
变量中删除"
(双引号)
Just remove "
(double quotes) from the start
and end
variable
<ion-item *ngFor='let item of items | slice:start:end'>
这篇关于在* ngFor中使用带有可变参数的Slice Pipe的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文