Évolution des formulaires d'ajout
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
label {
|
||||
display: inline-block;
|
||||
width: 150px;
|
||||
}
|
||||
|
||||
input[type="text"] {
|
||||
width: 200px;
|
||||
}
|
||||
|
||||
@@ -1 +1,7 @@
|
||||
<p>new-gear works!</p>
|
||||
<form [formGroup]="addForm" (ngSubmit)="onSubmit(addForm.value)">
|
||||
<div>
|
||||
<label for="aircraftName">Aircraft name</label>
|
||||
<input id="aircraftName" type="text" formControlName="aircraftName">
|
||||
</div>
|
||||
<button class="button" type="submit">Add</button>
|
||||
</form>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { FormControl, FormGroup, Validators } from '@angular/forms';
|
||||
|
||||
@Component({
|
||||
selector: 'app-new-gear',
|
||||
@@ -6,10 +7,21 @@ import { Component, OnInit } from '@angular/core';
|
||||
styleUrls: ['./new-gear.component.css']
|
||||
})
|
||||
export class NewGearComponent implements OnInit {
|
||||
public addForm: FormGroup;
|
||||
|
||||
constructor() { }
|
||||
constructor() {
|
||||
this.addForm = new FormGroup({
|
||||
aircraftName: new FormControl('', Validators.required)
|
||||
});
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
}
|
||||
|
||||
onSubmit(formData) {
|
||||
console.log(formData.status);
|
||||
console.warn('New data : ', formData);
|
||||
|
||||
this.addForm.reset();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user