Skip to content

Commit 4fc86f3

Browse files
committed
Angular Material In Depth
1 parent 8a0ce50 commit 4fc86f3

5 files changed

+56
-1
lines changed

src/app/app-routing.module.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {CourseResolver} from "./services/course.resolver";
77
import {CreateCourseComponent} from './create-course/create-course.component';
88
import {DragDropComponent} from './drag-drop/drag-drop.component';
99
import {TreeDemoComponent} from './tree-demo/tree-demo.component';
10+
import {VirtualScrollingComponent} from './virtual-scrolling/virtual-scrolling.component';
1011

1112
const routes: Routes = [
1213
{
@@ -36,6 +37,10 @@ const routes: Routes = [
3637
{
3738
path: "tree-demo",
3839
component: TreeDemoComponent
40+
},
41+
{
42+
path: 'virtual-scrolling',
43+
component: VirtualScrollingComponent
3944
},
4045
{
4146
path: "**",

src/app/app.module.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ import {DragDropComponent} from './drag-drop/drag-drop.component';
4545
import {MatGridListModule} from '@angular/material/grid-list';
4646
import {TreeDemoComponent} from './tree-demo/tree-demo.component';
4747
import {MatTreeModule} from '@angular/material/tree';
48+
import {VirtualScrollingComponent} from './virtual-scrolling/virtual-scrolling.component';
4849

4950
@NgModule({
5051
declarations: [
@@ -58,7 +59,8 @@ import {MatTreeModule} from '@angular/material/tree';
5859
CreateCourseStep1Component,
5960
CreateCourseStep2Component,
6061
DragDropComponent,
61-
TreeDemoComponent
62+
TreeDemoComponent,
63+
VirtualScrollingComponent
6264
],
6365
imports: [
6466
BrowserModule,
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
2+
<div class="container">
3+
4+
<div class="virtual-scrolling">
5+
6+
<h3>Virtual Scrolling Demo</h3>
7+
8+
<mat-list class="scrolling-container mat-elevation-z7">
9+
<mat-list-item *ngFor="let item of items"> {{item}} </mat-list-item>
10+
</mat-list>
11+
12+
</div>
13+
14+
</div>
15+
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
2+
.container {
3+
font-family: "Roboto";
4+
display: flex;
5+
justify-content: center;
6+
padding: 30px;
7+
}
8+
9+
10+
.scrolling-container {
11+
display: block;
12+
width: 200px;
13+
max-height: 200px;
14+
overflow-y: scroll;
15+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import {Component, OnInit} from '@angular/core';
2+
3+
4+
@Component({
5+
selector: "virtual-scrolling",
6+
templateUrl: 'virtual-scrolling.component.html',
7+
styleUrls: ["virtual-scrolling.component.scss"]
8+
})
9+
export class VirtualScrollingComponent implements OnInit {
10+
11+
items = Array.from({length: 100}).map((value, i) => `Item #${i}`);
12+
13+
ngOnInit() {
14+
15+
}
16+
17+
18+
}

0 commit comments

Comments
 (0)