From the course: Building Angular and ASP.NET Web API Apps
Unlock the full course today
Join today to access over 22,700 courses taught by industry experts or purchase this course individually.
Creating an HttpPost request in Angular
From the course: Building Angular and ASP.NET Web API Apps
Creating an HttpPost request in Angular
- [Instructor] So on this part, we are going to connect these two to each other. So we are going to create a method. Then we are going to inject our service in our new component. And then we are going to send the data, so we are going to send the request. So let's get started. In our entry.service.ts file, let us create a new method named createEntry. And this method will take as a parameter an entry. Once we have the entry we want to send the post request to our back end. So for that we write return.this.http.post because we want to send a post request, and we already have the base urls. So for that we write in here this.baseUrl. And then we are going to send the entry as a parameter. So this is all you have to do in your service. Now let us go back to our component and inject this service. So inside the new entry folder, go to your new-entry.component.ts file. And inside the constructor, let us inject our service. For that, write private service and then Entry Service. To use this…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
(Locked)
Creating a Web API HttpPost endpoint3m 48s
-
(Locked)
Configuring an Angular reactive form3m 40s
-
(Locked)
Creating an Angular reactive form7m 48s
-
(Locked)
Validating an Angular reactive form5m 41s
-
(Locked)
Designing a header and footer3m 36s
-
(Locked)
Creating an HttpPost request in Angular3m 18s
-
(Locked)
-
-
-
-
-