-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcourse-edit-modal.component.ts
39 lines (33 loc) · 1.06 KB
/
course-edit-modal.component.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import { Component, OnInit, Input } from "@angular/core";
import { Course } from "src/app/model/course";
import { NgbActiveModal } from "@ng-bootstrap/ng-bootstrap";
import { FormBuilder, FormGroup, Validators } from "@angular/forms";
@Component({
selector: "app-course-edit-modal",
templateUrl: "./course-edit-modal.component.html",
styleUrls: ["./course-edit-modal.component.css"]
})
export class CourseEditModalComponent implements OnInit {
@Input() course: Course;
@Input() title: string;
formGroup: FormGroup;
constructor(
private activeModal: NgbActiveModal,
private formBuilder: FormBuilder
) {}
ngOnInit(): void {
this.formGroup = this.formBuilder.group({
title: [this.course.title, Validators.required],
description: [this.course.description, Validators.required],
price: [this.course.price, Validators.required],
imgUrl: [this.course.imgUrl]
});
}
onSave(course: Course) {
course.id = this.course.id;
this.activeModal.close(course);
}
onClose() {
this.activeModal.dismiss("dismissed");
}
}