Skip to content

Commit a8bb148

Browse files
author
Your Name
committed
Angular Forms In Depth
1 parent 2b6b2b5 commit a8bb148

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

src/app/create-course/create-course-step-3/create-course-step-3.component.html

+3-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ <h3>Add Course Lessons:</h3>
55

66
<ng-container formArrayName="lessons">
77

8-
<ng-container *ngFor="let lessonForm of lessons.controls">
8+
<ng-container *ngFor="let lessonForm of lessons.controls; let i = index">
99

1010
<div class="lesson-form-row" [formGroup]="lessonForm">
1111

@@ -28,7 +28,8 @@ <h3>Add Course Lessons:</h3>
2828

2929
</mat-form-field>
3030

31-
<mat-icon class="delete-btn">delete_forever</mat-icon>
31+
<mat-icon class="delete-btn" (click)="deleteLesson(i)">
32+
delete_forever</mat-icon>
3233

3334
</div>
3435

src/app/create-course/create-course-step-3/create-course-step-3.component.ts

+10
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,14 @@ export class CreateCourseStep3Component {
3131

3232
this.lessons.push(lessonForm);
3333
}
34+
35+
deleteLesson(lessonIndex: number) {
36+
this.lessons.removeAt(lessonIndex);
37+
}
3438
}
39+
40+
41+
42+
43+
44+

0 commit comments

Comments
 (0)