providers create form added
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
import { Component } from '@angular/core';
|
||||
import {FormControl, FormGroup, ReactiveFormsModule, Validators} from "@angular/forms";
|
||||
import {NzFormModule} from "ng-zorro-antd/form";
|
||||
import {NzInputDirective} from "ng-zorro-antd/input";
|
||||
import {NzFlexDirective} from "ng-zorro-antd/flex";
|
||||
import {NzButtonComponent} from "ng-zorro-antd/button";
|
||||
|
||||
@Component({
|
||||
selector: 'app-providers-add-form',
|
||||
imports: [ReactiveFormsModule, NzFormModule, NzInputDirective,],
|
||||
templateUrl: './providers-add-form.html',
|
||||
styleUrl: './providers-add-form.css',
|
||||
})
|
||||
export class ProvidersAddForm {
|
||||
providerForm = new FormGroup({
|
||||
lastName: new FormControl<string>(null, [Validators.required]),
|
||||
firstName: new FormControl<string>(null, [Validators.required]),
|
||||
phoneNumber: new FormControl<string>(null, [Validators.required]),
|
||||
email: new FormControl<string>(null, [Validators.required]),
|
||||
address: new FormControl<string>(null, [Validators.required]),
|
||||
role: new FormControl<string>(null, [Validators.required]),
|
||||
price: new FormControl<string>(null, [Validators.required]),
|
||||
})
|
||||
submitForm() {
|
||||
// Pour annuler si le formulaire est invalide
|
||||
if (this.providerForm.invalid) return;
|
||||
|
||||
// Pour obtenir la valeur du formulaire
|
||||
console.log(this.providerForm.getRawValue())
|
||||
|
||||
// Pour vider le formulaire
|
||||
this.providerForm.reset()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user