DELETE: Remove User+ UI Cleanup

In this tutorial, we implement the Delete functionality and add simple UI improvements to make the application more user-friendly.


delete(id: number) {
  if(confirm("Are you sure?")) {
    this.userService.deleteUser(id).subscribe(() => {
      this.ngOnInit();
    });
  }
}

Explanation

1. Confirm Before Deleting: Before removing a user record, a confirmation pop-up appears using the browser’s built-in confirm() method.
This prevents accidental deletions and ensures the user intentionally clicks the delete button.

2. Performing the Delete Operation: If the user clicks OK, the method calls


this.userService.deleteUser(id)