web-dave / angular_workshop

0 stars 0 forks source link

Create a Book #14

Open web-dave opened 2 months ago

web-dave commented 2 months ago
indexd Forme Type ```ts export type IForm = { [K in keyof T]: FormControl; }; ```
book-new.component.ts ```ts import { Validators, FormBuilder, FormGroup } from '@angular/forms'; ... form: FormGroup>; constructor(private formBuilder: FormBuilder) { } ngOnInit() { this.form = this.formBuilder.nonNullable.group({ title: ['', [Validators.required, Validators.minLength(6)]], isbn: ['', [Validators.required, Validators.minLength(6)]], id: ['', []], subtitle: ['', []], abstract: ['', []], author: ['', []], publisher: ['', []], price: ['', []], numPages: [0, []], cover: ['', []], userId: [0, []], }); } ```
books.service.ts ```ts createBook(book): Observable { const url = `${this.restRoot}`; return this.http.post(url, book); } ```
web-dave commented 2 months ago

NEXT