From the course: Building Angular and ASP.NET Web API Apps (2018)
Unlock the full course today
Join today to access over 24,400 courses taught by industry experts.
Creating an HttpDelete request in Angular
From the course: Building Angular and ASP.NET Web API Apps (2018)
Creating an HttpDelete request in Angular
- [Instructor] Now that we have created our view, and we have created the web API endpoint let us go and extend our service with one additional method which is going to connect these two with each other. So for that let us go to our Angular project. Inside this project, go to the entry.service.ts file. Scroll down to the bottom, and here let us create our new method. We're going to name this method deleteEntry. And as a parameter we're going to have an id. Then next, let us send a request to our API endpoint. So for that we write return this.http.delete. Because we want to send an http delete request and then in here define the baseUrl, and then to this baseUrl let us append our id. So for that you write plus, then single quotes, slash, and then append the id in here. That is all you have to do in your service now let us go back to our delete component.ts file. So we have in here two methods, the cancel method and the confirm method. When the user clicks the cancel button we want to…
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.