-1

I'm using angular7 with loopback API. I want make delete code in tables. Can you suggest me.

But I tried some code it's not working. I have attached my code here..

file.component.html

    <td><button class="btn btn-success" (click)="deleteUser(user)"> Delete</button></td>

file.component.ts

   deleteUser(user: User): void {
this.apiService.deleteUser(user.id);
 };

api.service.ts

deleteUser(id: number): Observable<ApiResponse> {
return this.http.delete<ApiResponse>(this.baseUrl + id);
}

Also give me all the operation codes like update delete

Mokka soru
  • 503
  • 2
  • 4
  • 12

1 Answers1

1

First thing, you didn't subscribe, so the request didn't go out.

deleteUser(user: User): void {
   this.apiService.deleteUser(user.id).subscribe();
};
mbojko
  • 13,503
  • 1
  • 16
  • 26