Advertisement
Guest User

Untitled

a guest
Jul 25th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.18 KB | None | 0 0
  1. <div style="text-align:center">
  2. <button class="btn" (click)='populateList()'>Click</button>
  3. <h1>Bla</h1>
  4. <virtual-scroll [items]="listOfItems" (update)="smallList = onUpdateOfList($event)">
  5. <div *ngFor="let item of smallList">{{item}}</div>
  6. </virtual-scroll>
  7. </div>
  8.  
  9. @Component({
  10. selector: '-deliverable-list',
  11. templateUrl: './delivereble-list.custom-component.html',
  12. styleUrls: ['./deliverable-list.component.scss']
  13. })
  14. //EXPERIMENTS
  15. populate: boolean = false;
  16. listOfItems: string[] = [];
  17. smallList: any[] = [];
  18.  
  19. private populateList() {
  20. this.listOfItems = [];
  21. if (this.populate) {
  22. for (let i = 0; i < 200; i++) {
  23. this.listOfItems.push("inne: " + i);
  24. }
  25. this.populate = false;
  26. }
  27. else {
  28. for (let i = 0; i < 200; i++) {
  29. 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.");
  30. }
  31. this.populate = true;
  32. }
  33. //console.log(this.listOfItems);
  34. }
  35.  
  36. private onUpdateOfList(event: any[]): any[] {
  37. if (event.length != 0) {
  38. this.smallList = event;
  39. } else {
  40. this.smallList = this.listOfItems.slice(10, 20);
  41. }
  42. console.log(this.smallList);
  43. return this.smallList;
  44. }
  45. //EXPERIMENTS
  46.  
  47. <!--The content below is only a placeholder and can be replaced.-->
  48. <div style="text-align:center">
  49. <button class="btn" (click)='populateList()'>Click</button>
  50. <h1>Bla</h1>
  51. <virtual-scroll [items]="listOfItems" (update)="scrollItem = $event">
  52. <div *ngFor="let item of scrollItem">{{item}}</div>
  53. </virtual-scroll>
  54. </div>
  55.  
  56. import { Component ,OnInit} from '@angular/core';
  57.  
  58. @Component({
  59. selector: 'app-root',
  60. templateUrl: './app.component.html',
  61. styleUrls: ['./app.component.scss']
  62. })
  63. export class AppComponent implements OnInit {
  64.  
  65. ble:boolean = false;
  66. listOfItems: string [] = [];
  67. //scrollItem: any[];
  68. ngOnInit(): void {
  69.  
  70. }
  71.  
  72. populateList():void{
  73. this.listOfItems = [];
  74. if(this.ble){
  75. for(let i = 0; i<200 ; i++){
  76. this.listOfItems.push("Lorem ipsum dolor sit amet, consectetur
  77. adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore
  78. magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation
  79. ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute
  80. irure dolor in reprehenderit in voluptate velit esse cillum dolore eu
  81. fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
  82. proident, sunt in culpa qui officia deserunt mollit anim id est
  83. laborum.");
  84. }
  85. this.ble = false;
  86. }
  87. else{
  88. for(let i = 0; i<200 ; i++){
  89. this.listOfItems.push("inne: " + i);
  90. }
  91. this.ble = true;
  92. }
  93. //console.log(this.scrollItem);
  94. console.log(this.listOfItems);
  95. }
  96.  
  97. onUpdate(list: any[]): any[]{
  98. //this.scrollItem = list;
  99. // return this.scrollItem;
  100. return null;
  101. }
  102. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement