Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typescript/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular 如何将ngFor用于4个元素?_Angular_Typescript_Angular Pipe - Fatal编程技术网

Angular 如何将ngFor用于4个元素?

Angular 如何将ngFor用于4个元素?,angular,typescript,angular-pipe,Angular,Typescript,Angular Pipe,现在我使用: 把所有的元素都带出来。 但我需要拿出4div元素。 像这样: 我怎么能用ngFor做到这一点? 我有一个滑块,需要在开始时显示4个元素。使用SlicePipe: <app ngxSlickItem *ngFor="let item of items | slice:0:4" [item]="item"></app> 什么是app?您是否询问如何将所有项目的[item]分配给项目?如果是这样的话,*ngFor需要进入你已经有的div标签现在我有了:它

现在我使用:


把所有的元素都带出来。 但我需要拿出4div元素。 像这样:


我怎么能用ngFor做到这一点?
我有一个滑块,需要在开始时显示4个元素。

使用
SlicePipe

<app ngxSlickItem *ngFor="let item of items | slice:0:4" [item]="item"></app>

什么是
app
?您是否询问如何将所有项目的
[item]
分配给
项目
?如果是这样的话,*ngFor需要进入你已经有的
div
标签现在我有了:它显示了我所有的[item]我需要使用ngFor来删除4个div-element你说的“first”和“second”是什么意思?@WatchAllMovie
slice:0:4
-0和4是传递给
SlicePipe
的两个参数,这是Angular向管道传递参数的语法。我只有4个元素,是吗?因为我有一个滑块,我需要显示4个元素start@WatchAllMovie是的,这将只获得前四个元素。好的,谢谢)我仍然可以滚动到下一个元素?