Évolution des formulaires d'ajout
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
label {
|
||||
display: inline-block;
|
||||
width: 150px;
|
||||
}
|
||||
|
||||
input[type="text"] {
|
||||
width: 200px;
|
||||
}
|
||||
|
||||
input[type="email"] {
|
||||
width: 200px;
|
||||
}
|
||||
|
||||
@@ -1 +1,23 @@
|
||||
<p>new-drop-zone works!</p>
|
||||
<form [formGroup]="addForm" (ngSubmit)="onSubmit(addForm.value)">
|
||||
<div>
|
||||
<label for="dzName">Dropzone name</label>
|
||||
<input id="dzName" type="text" formControlName="dzName">
|
||||
</div>
|
||||
<div>
|
||||
<label for="gps">GPS</label>
|
||||
<input id="gps" type="text" formControlName="gps">
|
||||
</div>
|
||||
<div>
|
||||
<label for="address">Address</label>
|
||||
<textarea id="address" type="text" formControlName="address" placeholder="Address of the DZ">
|
||||
</div>
|
||||
<div>
|
||||
<label for="contactMail">Mail of contact</label>
|
||||
<input id="contactMail" type="email" formControlName="contactMail">
|
||||
</div>
|
||||
<div>
|
||||
<label for="type">DZ or/and tunnel</label>
|
||||
<input id="type" type="text" formControlName="type">
|
||||
</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-drop-zone',
|
||||
@@ -6,10 +7,25 @@ import { Component, OnInit } from '@angular/core';
|
||||
styleUrls: ['./new-drop-zone.component.css']
|
||||
})
|
||||
export class NewDropZoneComponent implements OnInit {
|
||||
public addForm: FormGroup;
|
||||
|
||||
constructor() { }
|
||||
constructor() {
|
||||
this.addForm = new FormGroup({
|
||||
dzName: new FormControl('', Validators.required),
|
||||
gps: new FormControl('x.x,y.y', Validators.required),
|
||||
address: new FormControl('', Validators.required),
|
||||
contactMail: new FormControl('tot@toto.fr', Validators.required),
|
||||
type: new FormControl('[dz]', Validators.required)
|
||||
});
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
}
|
||||
|
||||
onSubmit(formData) {
|
||||
console.log(formData.status);
|
||||
console.warn('New data : ', formData);
|
||||
|
||||
this.addForm.reset();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user