Files
gilze-angular/app/pages/user/form/edit-user-form.component.ts
T
2026-06-17 16:11:25 +02:00

43 lines
968 B
TypeScript

import {Component, Input, OnInit} from '@angular/core';
import {User} from "../../../classes/user.class";
import {DataService} from './../../../services/data.service';
import {NgForm} from '@angular/forms';
@Component({
selector: 'edit-user-form',
templateUrl: './edit-user-form.component.html'
})
export class EditUserFormComponent implements OnInit {
@Input()model:User;
user:User;
constructor(private data: DataService) {
}
temp: string;
roles = ['Pilot', 'Student', 'Instructor'];
submitted = false;
ngOnInit()
{
this.user = new User(this.model.id, this.model.name, this.model.card, this.model.role);
}
onSubmit() {
this.model.name = this.user.name;
this.model.role = this.user.role;
this.submitted = true;
this.data.load().then(() => {
this.data.editUser(this.model).subscribe(b => this.temp = JSON.stringify(b));
console.log(this.temp);
})
}
}