O'Reilly logo

Learning Angular for .NET Developers by Rajesh Gunasundaram

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Calling the DELETE action of the Web API to delete a Todo item

We added code to get, add, and edit a Todo item by calling various Web API actions, such as GET, POST, and PUT, respectively. Now, let's consume the DELETE action in the Web API to delete a matching Todo item. Follow the given steps to do so:

  1. Open todo.service.ts.
  2. Add the deleteTodo function with the following code snippet to delete a matching Todo item by calling the DELETE action in the Web API:
      deleteTodo(todo: Todo) {         this.http.delete('/api/todos/' + todo.id)             .subscribe(err => console.log(err),             () => console.log('getTodos Complete')             );          } 

This code calls the DELETE action along with the id of the Todo item being deleted. The Web API's DELETE action method will retrieve ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required