Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

217
Views
ngb modal pass the data to when form edit angular

I am using ngb modal for my form edit. this is my edit button function

  editCheckin(data: CheckInModel, details: any) {
console.log(data);
this.modalService.open(details, { ariaLabelledBy: 'modal-basic-title', size: 'xl', backdrop: 'static' }).result.then((id) => {
}, (reason) => {

});

} When I click the edit button, above function call and loading popup correctly. This is my edit button

  <button mat-stroked-button type="button" class="action-btn"
                                    (click)="editCheckin(element, details)">
                                    <i class="fas fa-pencil-alt"></i>
                                </button>

edit object passed correctly. console.log(data) result is like below

enter image description here

now i need to that console logged data to my pop up. how i pass it.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You can edit the component instance directly doing something like

in your modal you add a property :

data: CheckInModel

and when you call the modal you just do :

openModal() {
   const modalRef = this.modalService.open(ModalContentComponent);
   modalRef.componentInstance.data = this.data;
}

In my app, I have a custom service that wrap the ngb modal service :

export class ModalService {
  constructor(private modalService: NgbModal) {}

  open<C, T>(content: unknown, config?: T, options?: NgbModalOptions): ModalRef<C> {
    const modal = this.modalService.open(content, {
      centered: true,
      backdrop: true,
      size: 'm',
      ...options,
    });
    Object.assign(modal.componentInstance, config);
    return modal;
  }
}

This way I can simply call my modal with my service and pass the data :

    const ref = this.modalService.open<GenericModalComponent, GenericModalData>(
      GenericModalComponent,
      {
        data: 'this will be passed to the modal instance'
      }
    );

The important thing is that the modal have a defined property with the same name (here would be data)

more Here

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!