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

Discussão em 'Angular' iniciado por Aakash Singh, Fevereiro 4, 2025.

  1. Aakash Singh

    Aakash Singh Guest

    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 class="btn btn-primary" (click)="deleteSource(source.id)" style="margin-left:5px">

    Continue reading...

Compartilhe esta Página