Questions Management – Frontend – Build question deletion using Angular

Check out the full series of Questions Management tutorial here.

In the previous tutorial, we built the questionnaire display with the corresponding delete button for each question. In this tutorial, we will implement the function of this button!

First, I will add a new method to the QuestionService class that will allow us to call the API delete question of API Question Service to pass information about the question that we need to delete.

Specifically, this method is as follows:

Next we will also add a new method in the AllQuestionsComponent to make the delete question as follows:

As you can see, after confirming the deletion of the question, I called the deleteQuestion() method of the QuestionsService we just added above.

Finally, we will revise the delete question button in the all_questions.component.html file to call the deleteQuestion() method in the AllQuestionsComponent class when the user clicks on this button.



OK, so we have added functionality for deleting button. Let’s run it.

On the All Questions page, delete any question by clicking the delete button, which will look like this:

Questions Management – Frontend – Build question deletion

Press the OK button to confirm deletion of this question.

Đánh giá bài viết
Chia sẽ bài viết này ...Share on Facebook
0Tweet about this on Twitter
Share on LinkedIn

Add Comment