Skip to content

Commit e548cba

Browse files
author
Your Name
committed
Angular Material In Depth
1 parent 0b917d5 commit e548cba

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

src/app/course/course.component.html

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,11 @@ <h2>{{course?.description}}</h2>
4848

4949
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
5050

51-
<tr mat-row *matRowDef="let lesson;columns:displayedColumns"></tr>
51+
<tr mat-row
52+
(click)="onToggleLesson(lesson)"
53+
*matRowDef="let lesson;columns:displayedColumns">
54+
55+
</tr>
5256

5357
<tr mat-row *matRowDef="let lesson;columns:['expandedDetail']"></tr>
5458

src/app/course/course.component.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ export class CourseComponent implements OnInit, AfterViewInit {
3636

3737
displayedColumns = ['seqNo', "description", "duration"];
3838

39+
expandedLesson: Lesson = null;
40+
3941
ngOnInit() {
4042

4143
this.course = this.route.snapshot.data["course"];
@@ -68,6 +70,16 @@ export class CourseComponent implements OnInit, AfterViewInit {
6870

6971
}
7072

73+
onToggleLesson(lesson:Lesson) {
74+
if (lesson == this.expandedLesson) {
75+
this.expandedLesson = null;
76+
}
77+
else {
78+
this.expandedLesson = lesson;
79+
}
80+
81+
}
82+
7183
ngAfterViewInit() {
7284

7385
this.sort.sortChange.subscribe(() => this.paginator.pageIndex = 0);
@@ -89,3 +101,12 @@ export class CourseComponent implements OnInit, AfterViewInit {
89101

90102

91103

104+
105+
106+
107+
108+
109+
110+
111+
112+

0 commit comments

Comments
 (0)