diff --git a/src/app/components/create-book/create-book.css b/src/app/components/create-book/create-book.css new file mode 100644 index 0000000..e69de29 diff --git a/src/app/components/create-book/create-book.html b/src/app/components/create-book/create-book.html new file mode 100644 index 0000000..7df8a6a --- /dev/null +++ b/src/app/components/create-book/create-book.html @@ -0,0 +1,33 @@ +
+ + + Nom + + + + + + + + + + Prénom + + + + + + + + + + + + + + +
+ + \ No newline at end of file diff --git a/src/app/components/create-book/create-book.ts b/src/app/components/create-book/create-book.ts new file mode 100644 index 0000000..20de703 --- /dev/null +++ b/src/app/components/create-book/create-book.ts @@ -0,0 +1,28 @@ +import { Component } from '@angular/core'; +import {NzFormModule} from "ng-zorro-antd/form"; +import {FormControl, FormGroup, Validators} from "@angular/forms"; + +@Component({ + selector: 'app-create-book', + imports: [NzFormModule], + templateUrl: './create-book.html', + styleUrl: './create-book.css', +}) +export class CreateBook { + createBookForm = new FormGroup({ + title: new FormControl(null, [Validators.required]), + releaseYear: new FormControl(null, [Validators.required]), + author: new FormControl(null, [Validators.required]) + }) + + submitForm() { + // Pour annuler si le formulaire est invalide + if (this.createBookForm.invalid) return; + + // Pour obtenir la valeur du formulaire + console.log(this.createBookForm.getRawValue()) + + // Pour vider le formulaire + this.createBookForm.reset() + } +}