Implementing the Delete feature

Before going further, we can take the chance to add a Delete Quiz button to our QuizController and bind it to another event-handler method that will take care of the client-server interactions required to actually execute the delete action.

Let's start with creating the button in the quiz.component.html template file; we can put it just below the Edit button:

[...]<div>    <input type="button" value="Edit" (click)="onEdit()" />    <input type="button" value="Delete this Quiz" (click)="onDelete()" /></div>[...]

Once done, add the following onDelete() method implementation in the quiz.component.ts file, right below the onEdit() method:

[...]onDelete() {    if (confirm("Do you really want to delete this quiz?")) { var ...

Get ASP.NET Core 2 and Angular 5 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.