35 lines
771 B
TypeScript
35 lines
771 B
TypeScript
import { Component, Inject, OnInit } from '@angular/core';
|
|
import { FormBuilder, FormGroup } from '@angular/forms';
|
|
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
|
|
|
|
@Component({
|
|
selector: 'app-pax',
|
|
templateUrl: './pax.component.html',
|
|
styleUrls: ['./pax.component.css'],
|
|
})
|
|
export class PaxComponent implements OnInit {
|
|
form: FormGroup;
|
|
|
|
constructor(
|
|
public dialogRef: MatDialogRef<PaxComponent>,
|
|
@Inject(MAT_DIALOG_DATA) public data: number,
|
|
private fb: FormBuilder,
|
|
) {
|
|
// Create form
|
|
this.form = this.fb.group({
|
|
pax: '',
|
|
});
|
|
}
|
|
|
|
ngOnInit() {
|
|
this.form.setValue({
|
|
pax: this.data,
|
|
});
|
|
}
|
|
|
|
accept(): void {
|
|
const pax = +this.form.value.pax;
|
|
this.dialogRef.close(pax);
|
|
}
|
|
}
|