Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <div style="text-align:center">
- <button class="btn" (click)='populateList()'>Click</button>
- <h1>Bla</h1>
- <virtual-scroll [items]="listOfItems" (update)="smallList = onUpdateOfList($event)">
- <div *ngFor="let item of smallList">{{item}}</div>
- </virtual-scroll>
- </div>
- @Component({
- selector: '-deliverable-list',
- templateUrl: './delivereble-list.custom-component.html',
- styleUrls: ['./deliverable-list.component.scss']
- })
- //EXPERIMENTS
- populate: boolean = false;
- listOfItems: string[] = [];
- smallList: any[] = [];
- private populateList() {
- this.listOfItems = [];
- if (this.populate) {
- for (let i = 0; i < 200; i++) {
- this.listOfItems.push("inne: " + i);
- }
- this.populate = false;
- }
- else {
- for (let i = 0; i < 200; i++) {
- this.listOfItems.push("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.");
- }
- this.populate = true;
- }
- //console.log(this.listOfItems);
- }
- private onUpdateOfList(event: any[]): any[] {
- if (event.length != 0) {
- this.smallList = event;
- } else {
- this.smallList = this.listOfItems.slice(10, 20);
- }
- console.log(this.smallList);
- return this.smallList;
- }
- //EXPERIMENTS
- <!--The content below is only a placeholder and can be replaced.-->
- <div style="text-align:center">
- <button class="btn" (click)='populateList()'>Click</button>
- <h1>Bla</h1>
- <virtual-scroll [items]="listOfItems" (update)="scrollItem = $event">
- <div *ngFor="let item of scrollItem">{{item}}</div>
- </virtual-scroll>
- </div>
- import { Component ,OnInit} from '@angular/core';
- @Component({
- selector: 'app-root',
- templateUrl: './app.component.html',
- styleUrls: ['./app.component.scss']
- })
- export class AppComponent implements OnInit {
- ble:boolean = false;
- listOfItems: string [] = [];
- //scrollItem: any[];
- ngOnInit(): void {
- }
- populateList():void{
- this.listOfItems = [];
- if(this.ble){
- for(let i = 0; i<200 ; i++){
- this.listOfItems.push("Lorem ipsum dolor sit amet, consectetur
- adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore
- magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation
- ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute
- irure dolor in reprehenderit in voluptate velit esse cillum dolore eu
- fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
- proident, sunt in culpa qui officia deserunt mollit anim id est
- laborum.");
- }
- this.ble = false;
- }
- else{
- for(let i = 0; i<200 ; i++){
- this.listOfItems.push("inne: " + i);
- }
- this.ble = true;
- }
- //console.log(this.scrollItem);
- console.log(this.listOfItems);
- }
- onUpdate(list: any[]): any[]{
- //this.scrollItem = list;
- // return this.scrollItem;
- return null;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement