The code to add a book is rather simple. The user is presented with a form that needs to be filled out. This form contains information about the book (title, author and ISBN) as well as a submit button. Each filed has a corresponding ID. For instance the input field for the title of the book is identifying by bookTitle. We will see later why we need these IDs. We also want to add some styling to improve the looks of our form.
To be able to reference a bookForm, we first have to build a form and specify the fields that we want our form to hold.
When a form is submitted, the function onSubmit() is called and it takes as an argument the value of the form bookForm.value.
As a matter of fact, when a book is submitted, all we need to do is to call the service responsible for adding a book with the information that was just submitted.
In any good navigation design, the user should be able to intuitively navigate through the website. To achieve that, we have to offer the user a way through which they can access the add book component as well as exit it or go back to a previous component (book listing component).
Let us go back to the book list component that we have previously created and add a button that redirects the user to the route that we defined for our add book component.