From 76b6f74086bb7b61f8cf831f241c62fe5a3a6b4d Mon Sep 17 00:00:00 2001 From: sanchezvem Date: Mon, 10 Nov 2025 16:57:16 +0100 Subject: [PATCH] insert form into book --- .../components/create-book/create-book.css | 0 .../components/create-book/create-book.html | 33 +++++++++++++++++++ src/app/components/create-book/create-book.ts | 28 ++++++++++++++++ 3 files changed, 61 insertions(+) create mode 100644 src/app/components/create-book/create-book.css create mode 100644 src/app/components/create-book/create-book.html create mode 100644 src/app/components/create-book/create-book.ts 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() + } +}