Skip to content

Commit bb3b8ab

Browse files
author
Your Name
committed
Angular Forms In Depth
1 parent 0f69262 commit bb3b8ab

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

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

+13
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,19 @@ export class CreateCourseStep1Component implements OnInit {
4444

4545
this.courseCategories$ = this.courses.findCourseCategories();
4646

47+
const draft = localStorage.getItem("STEP_1");
48+
49+
if (draft) {
50+
this.form.setValue(JSON.parse(draft));
51+
}
52+
53+
this.form.valueChanges
54+
.pipe(
55+
filter(() => this.form.valid)
56+
)
57+
.subscribe( val => localStorage.setItem("STEP_1", JSON.stringify(val)));
58+
59+
4760
}
4861

4962
get courseTitle() {

0 commit comments

Comments
 (0)