November 2019
Beginner
804 pages
20h 1m
English
The last method that we need to implement is removeBook. Here, we'll simply retrieve the DOM node corresponding to the book (that is, the table row) and remove it:
removeBook(collectionIdentifier: string, bookIdentifier: string) {
if (!collectionIdentifier) {
throw new Error("The collection identifier must be provided!");
}
if (!bookIdentifier) {
throw new Error("The book identifier must be provided!");
}
const bookElement = document.getElementById (`book-${collectionIdentifier}-${bookIdentifier}`) as HTMLInputElement;
if (!bookElement) {
throw new Error("The element corresponding to the book to remove could not be found! Did the template change?");
}
bookElement.remove();
}
Voilà! Our view is now fully ...
Read now
Unlock full access