Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular condition slicepipe in a ngfor [duplicate]

I want to know how can I use an conditional slicepipe in an ngFor to control the data displayed ?

For example to choose the number of videos displayed on a list/grid for example like these commons dropdowns :

imageref1

What I'm trying to do now is:

<app-example
      class="items-list-item"
      *ngFor="let item of datas.video | slice:0:1"
      [itemvideo]='item'>
</app-example>

But how I can do this dynamically when I change the value on the select dropdown ?

like image 837
Satanas Avatar asked Jun 13 '26 04:06

Satanas


1 Answers

You just need to define the variable and assign those values

 start : number = 1;
 end : number = 5;

then change it according to the dropdown value

this.end = yourdropdownval;

and the ngFor will look like,

<app-example class="items-list-item" *ngFor="let item of datas.video  | slice:start:end'>
like image 190
Sajeetharan Avatar answered Jun 15 '26 22:06

Sajeetharan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!