Home > other >  i need to update the list immediately, once data is deleted in angular 13 component
i need to update the list immediately, once data is deleted in angular 13 component

Time:12-10

I am deleting an object from the component, and i need to update the list immediately once the object is deleted, without refreshing the page. component.ts

deleteSource(id: any){
  if(confirm("Are you sure to delete?")){
  console.log(id)
    this.sourcesService.deleteSource(id).subscribe();
    }
    }

service.ts

 deleteSource(id: string): Observable<number>{

     return this.http.delete<number>(this.API_URL  id);
  }

component.html

<button  (click)="deleteSource(source.id)" style="margin-left:5px">

CodePudding user response:

I just had to call get again in the subscribe

this.sourcesService.deleteSource(id).subscribe(source =>  this.Source());
  • Related