Skip to content

Commit 9c32453

Browse files
author
Your Name
committed
Angular Forms In Depth
1 parent 9ee39df commit 9c32453

File tree

3 files changed

+38
-4
lines changed

3 files changed

+38
-4
lines changed

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,18 @@
2727

2828
</mat-form-field>
2929

30+
<mat-checkbox color="primary" formControlName="downloadsAllowed">
31+
Downloads allowed?
32+
</mat-checkbox>
33+
34+
<mat-form-field appearance="outline">
35+
36+
<textarea matInput placeholder="Description" formControlName="longDescription">
37+
38+
</textarea>
39+
40+
</mat-form-field>
41+
3042
</div>
3143

3244
<div class="form-val">

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ export class CreateCourseStep1Component implements OnInit {
2222
asyncValidators: [courseTitleValidator(this.courses)],
2323
updateOn: 'blur'
2424
}],
25-
releasedAt: [new Date(), Validators.required]
25+
releasedAt: [new Date(), Validators.required],
26+
downloadsAllowed: [false, Validators.requiredTrue],
27+
longDescription: ['', [Validators.required, Validators.minLength(3)]]
2628
});
2729

2830
constructor(private fb: FormBuilder, private courses:CoursesService) {

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

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@
33

44
<h2 class="title">Create New Course</h2>
55

6-
<mat-horizontal-stepper class="mat-elevation-z5" labelPosition="bottom">
6+
<mat-horizontal-stepper [linear]="true"
7+
class="mat-elevation-z5" labelPosition="bottom">
78

8-
<mat-step>
9+
<mat-step [stepControl]="step1.form">
910

1011
<ng-template matStepLabel>course landing page details</ng-template>
1112

12-
<create-course-step-1></create-course-step-1>
13+
<create-course-step-1 #step1></create-course-step-1>
1314

1415
<div class="stepper-buttons">
1516

@@ -19,6 +20,25 @@ <h2 class="title">Create New Course</h2>
1920

2021
</mat-step>
2122

23+
24+
<mat-step>
25+
26+
<create-course-step-2></create-course-step-2>
27+
28+
<ng-template matStepLabel>course pricing details</ng-template>
29+
30+
<div class="stepper-buttons">
31+
32+
<button mat-raised-button matStepperPrevious>Back</button>
33+
34+
<button mat-raised-button color="primary" matStepperNext>
35+
Continue to Step 3</button>
36+
37+
</div>
38+
39+
40+
</mat-step>
41+
2242
</mat-horizontal-stepper>
2343

2444

0 commit comments

Comments
 (0)