41 lines
1.1 KiB
TypeScript
41 lines
1.1 KiB
TypeScript
import {Component, Input, OnInit } from '@angular/core';
|
|
import {Plane} from "../../../classes/plane.class";
|
|
import {DataService} from './../../../services/data.service';
|
|
import {NgForm} from '@angular/forms';
|
|
|
|
@Component({
|
|
selector: 'edit-plane-form',
|
|
templateUrl: './edit-plane-form.component.html'
|
|
})
|
|
|
|
export class EditPlaneFormComponent implements OnInit{
|
|
|
|
@Input()plmodel:Plane;
|
|
|
|
plane:Plane;
|
|
|
|
constructor(private data: DataService) {
|
|
|
|
}
|
|
|
|
temp: string;
|
|
submitted = false;
|
|
|
|
ngOnInit(){
|
|
this.plane = new Plane(this.plmodel.id, this.plmodel.name, this.plmodel.registration, this.plmodel.model, this.plmodel.comment);
|
|
}
|
|
|
|
onSubmit() {
|
|
this.plmodel.name = this.plane.name;
|
|
this.plmodel.registration = this.plane.registration;
|
|
this.plmodel.model = this.plane.model;
|
|
this.plmodel.comment = this.plmodel.comment;
|
|
|
|
this.submitted = true;
|
|
this.data.load().then(() => {
|
|
this.data.editPlane(this.plmodel).subscribe(b => this.temp = JSON.stringify(b));
|
|
console.log(this.temp);
|
|
})
|
|
}
|
|
}
|