Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3622d4f

Browse files
docs(template): add import statements for virtual-view
1 parent 943176e commit 3622d4f

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

apps/docs/docs/template/virtual-view-directive.mdx

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,27 @@ RxVirtualView is designed to work in combination with related directives:
4646

4747
### Show a widget when it's visible, otherwise show a placeholder
4848

49+
```typescript
50+
import {
51+
RxVirtualView,
52+
RxVirtualViewContent,
53+
RxVirtualViewObserver,
54+
RxVirtualViewPlaceholder,
55+
} from '@rx-angular/template/virtual-view';
56+
// Other imports...
57+
58+
@Component({
59+
selector: 'my-list',
60+
imports: [RxVirtualView, RxVirtualViewContent, RxVirtualViewObserver, RxVirtualViewPlaceholder],
61+
templateUrl: './my-list.component.html',
62+
styleUrls: ['./my-list.component.scss'],
63+
changeDetection: ChangeDetectionStrategy.OnPush,
64+
})
65+
export class MyListComponent {
66+
// Component code
67+
}
68+
```
69+
4970
```html
5071
<!-- use the root node (html) for the IntersectionObserver -->
5172
<div rxVirtualViewObserver [root]="null">
@@ -82,6 +103,27 @@ This will make sure you don't run into stuttery scrolling behavior and layout sh
82103
This example demonstrates how to use RxVirtualView to optimize lists by only rendering the visible list items.
83104
We are only rendering the `item` component when it's visible to the user. Otherwise, it gets replaced by an empty div.
84105

106+
```typescript
107+
import {
108+
RxVirtualView,
109+
RxVirtualViewContent,
110+
RxVirtualViewObserver,
111+
RxVirtualViewPlaceholder,
112+
} from '@rx-angular/template/virtual-view';
113+
// Other imports...
114+
115+
@Component({
116+
selector: 'my-list',
117+
imports: [RxVirtualView, RxVirtualViewContent, RxVirtualViewObserver, RxVirtualViewPlaceholder],
118+
templateUrl: './my-list.component.html',
119+
styleUrls: ['./my-list.component.scss'],
120+
changeDetection: ChangeDetectionStrategy.OnPush,
121+
})
122+
export class MyListComponent {
123+
// Component code
124+
}
125+
```
126+
85127
```html
86128
<div rxVirtualViewObserver class="container">
87129
@for (item of items; track item.id) {

0 commit comments

Comments
 (0)