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.

From:

to:

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.

Questions Management – Frontend – Build question deletion using Angular
Đánh giá bài viết
Chia sẽ bài viết này ...Share on Facebook
Facebook
3Tweet about this on Twitter
Twitter
Share on LinkedIn
Linkedin

Add Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.