gpt-3.5-turbo-0125· OpenAI
WildChat-4.8M (AI2)
const modalRef = this.modalService.open(ProductDetailsComponent); i add this to parent…
- User
const modalRef = this.modalService.open(ProductDetailsComponent); i add this to parent comp to open the modal and when open the modal there is button call api i want when click on this button the modal close and ngb-toast with success or error message
- Assistant
You can achieve this by adding a click event handler to the button in your ProductDetailsComponent that closes the modal and then displays an ngb-toast with the success or error message.
Here's an example of how you can achieve this:
- Add a click event handler to the button in your ProductDetailsComponent to close the modal and display an ngb-toast message:
// product-details.component.html <button (click)="onButtonClick()">Call API</button>// product-details.component.ts import { NgbToast } from 'ngx-bootstrap/toast'; onButtonClick() { // Call the API here // Close the modal this.activeModal.dismiss('Close'); // Display ngb-toast with success or error message this.toastService.show('API call successful', { classname: 'bg-success text-light', delay: 5000 }); // OR // this.toastService.show('API call failed', { classname: 'bg-danger text-light', delay: 5000 }); }