From the course: Building Angular and ASP.NET Core Applications

Unlock the full course today

Join today to access over 24,800 courses taught by industry experts.

Adding new data from Angular

Adding new data from Angular

- [Narrator] Now that we created a form, it's time to add the create functionality in our Angular app. For that we are first going to create a method in Angular service then we are going to inject the service in our component. Then we are going to add the form group to the form. Next, we'll send a request from our component and that the end, we are going to handle the response. So let's go to Visual Code and see this in action. In here we'll go inside the client app and the inside source. App, services and the book_service.ts. Here we are going to create a method named addBook which will take, as a parameter, a book of type book and it will simply return this.http.post and then here write this.baseURL plus, inside double quotes, write / AddBook. Then to this post request we are going to parse, as a parameter, the book. Now let us go to our component, so inside the component go to the new-book folder then…

Contents