Skip to content

Commit

Permalink
tree | lazyload demo stackblitz update
Browse files Browse the repository at this point in the history
  • Loading branch information
mehmetcetin01140 committed Jan 4, 2024
1 parent d7f077c commit da6dbb1
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/app/showcase/doc/tree/lazydoc.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ChangeDetectorRef, Component, OnInit } from '@angular/core';
import { Component, OnInit, ChangeDetectorRef } from '@angular/core';
import { MessageService, TreeNode } from 'primeng/api';
import { Code } from '../../domain/code';
import { NodeService } from '../../service/nodeservice';
Expand Down Expand Up @@ -55,7 +55,7 @@ export class LazyDoc implements OnInit {
</div>`,

typescript: `
import { Component, OnInit } from '@angular/core';
import { Component, OnInit, ChangeDetectorRef } from '@angular/core';
import { MessageService, TreeNode } from 'primeng/api';
import { NodeService } from '../../service/nodeservice';
Expand All @@ -69,13 +69,14 @@ export class TreeLazyDemo implements OnInit {
files!: TreeNode[];
constructor(private nodeService: NodeService, private messageService: MessageService) { }
constructor(private nodeService: NodeService, private messageService: MessageService, private cd: ChangeDetectorRef) {}
ngOnInit() {
this.loading = true;
setTimeout(() => {
this.nodeService.getLazyFiles().then((files) => (this.files = files));
this.loading = false;
this.cd.markForCheck();
}, 1000);
}
Expand All @@ -88,6 +89,7 @@ export class TreeLazyDemo implements OnInit {
this.messageService.add({ severity: 'info', summary: 'Children Loaded', detail: event.node.label });
});
this.loading = false;
this.cd.markForCheck();
}, 200);
}
}
Expand Down

0 comments on commit da6dbb1

Please sign in to comment.