34 lines
990 B
TypeScript
34 lines
990 B
TypeScript
import { Component, OnInit } from "@angular/core";
|
|
import { FormControl, FormGroup, Validators } from "@angular/forms";
|
|
import { AircraftService } from "../../services/aircraft.service";
|
|
import { ServiceComm } from "../../services/service-comm.service";
|
|
import { AddAction } from "../../models/add-action.enum";
|
|
|
|
@Component({
|
|
selector: "app-new-aircraft",
|
|
templateUrl: "./new-aircraft.component.html",
|
|
styleUrls: ["./new-aircraft.component.css"]
|
|
})
|
|
export class NewAircraftComponent implements OnInit {
|
|
public addForm: FormGroup;
|
|
|
|
constructor(
|
|
private serviceComm: ServiceComm,
|
|
private serviceApi: AircraftService
|
|
) {
|
|
this.addForm = new FormGroup({
|
|
aircraftName: new FormControl("", Validators.required)
|
|
});
|
|
}
|
|
|
|
ngOnInit() {}
|
|
|
|
onSubmit(formData) {
|
|
this.serviceApi.AddAircraft(formData.value.aircraftName);
|
|
this.serviceComm.RefreshData(AddAction.Aircraft);
|
|
|
|
this.serviceComm.RefreshData(AddAction.Aircraft);
|
|
this.addForm.reset();
|
|
}
|
|
}
|