web-dave / angular-essentials-workshop

2 stars 0 forks source link

Edit a Book #19

Open web-dave opened 2 years ago

web-dave commented 2 years ago
web-dave commented 2 years ago
books-routing.module.ts ```ts { path: ':isbn/edit', component: BookEditComponent } ```
book-details.component.html ```html edit ```
books.module.ts ```typescript import { FormsModule } from '@angular/forms'; import ... @NgModule({ imports: [ CommonModule, BooksRoutingModule, FormsModule ], exports: [], declarations: [...], providers: [...] }) export class BooksModule { } ```
book-edit.component.html ```html
Enter a Title
...
X
```
book-edit.component.ts ```typescript saveBook() { this.booksService.updateBook(this.book) .subscribe(() => { this.router.navigate(['..'],{relativeTo:this.route}); }); } ```
book.service.ts ```typescript updateBook(book: IBook): Observable { const url = `${this.restRoot}/${book.isbn}`; return this.http.put(url, book); } ```
web-dave commented 2 years ago

Next