1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

Refresh page after NgbModal is closed

Discussão em 'Angular' iniciado por Ch_y, Outubro 1, 2024.

  1. Ch_y

    Ch_y Guest

    I have a component that uses an ngbModal to add some stuff to my data base, the problem is that when the Modal is closed and the POST action happens, I can't find a way to refresh the data displayed on my "parent page" (on the parent component I have a subscription that loads the data),

    So is there any way to refresh those data dynamically after closing the modal ?

    Or is there a way to bind data between two component? so that when data is changed on one, it changes on the other.

    This is the button that opens a modal (lgModalShow()), and in this component I call for the data,

    <button class="btn btn-success" (click)="lgModalShow()">Modal</button>

    lgModalShow() {
    const activeModal = this.modalService.open(DefaultModal, {size: 'lg'});
    activeModal.componentInstance.modalHeader = 'Large Modal';
    }


    this.service.getData(this.url)
    .subscribe(data => {
    this.data = data;
    },)


    In the DefaultModal I add the new data :

    add(): void {
    this.service.create(Object)
    .subscribe(data => {
    this.data = data;
    },)}


    Those are just the important snippets of the code, and the problem is that I don't know how to refresh the data in the first component after adding it in my modal.

    Continue reading...

Compartilhe esta Página