zgo/src/app/settings/settings.component.ts

41 lines
964 B
TypeScript
Raw Normal View History

2021-10-28 20:34:48 +00:00
import { Inject, Component, OnInit, OnDestroy, ViewEncapsulation } from '@angular/core';
import { MatDialog, MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
import { FormBuilder, Validators, FormGroup, FormControl } from '@angular/forms';
import {User} from '../user.model';
import {Owner} from '../owner.model';
@Component({
selector: 'app-settings',
templateUrl: './settings.component.html',
styleUrls: ['/settings.component.css']
})
export class SettingsComponent implements OnInit {
settingsForm: FormGroup;
owner: Owner;
constructor(
private fb: FormBuilder,
private dialogRef: MatDialogRef<SettingsComponent>,
@Inject(MAT_DIALOG_DATA) public data: Owner
) {
this.settingsForm = fb.group({
name: [data.name, Validators.required]
});
this.owner = data;
}
ngOnInit() {
}
close() {
this.dialogRef.close();
}
save() {
this.owner.name = this.settingsForm.value.name;
this.dialogRef.close(this.owner);
}
}