import { Component , Inject , OnInit } from '@angular/core' ; import { MAT_DIALOG_DATA , MatDialogRef } from "@angular/material/dialog" ; import { Course } from "../model/course" ; import { FormBuilder , Validators , FormGroup } from "@angular/forms" ; @ Component ( { selector : 'course-dialog' , templateUrl : './course-dialog.component.html' , styleUrls : [ './course-dialog.component.css' ] } ) export class CourseDialogComponent implements OnInit { form : FormGroup ; description : string ; constructor ( private fb , private dialogRef , @ Inject ( MAT_DIALOG_DATA ) { description , longDescription , category } ) { this . description = description ; this . form = fb . group ( { description : [ description , Validators . required ] , category : [ category , Validators . required ] , releasedAt : [ new Date ( ) , Validators . required ] , longDescription : [ longDescription , Validators . required ] } ) ; } ngOnInit ( ) { } save ( ) { this . dialogRef . close ( this . form . value ) ; } close ( ) { this . dialogRef . close ( ) ; } }