-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to pass data to modal ngx-bootstrap and receive return data ? #2290
Comments
help me, please! |
// How to pass data to modal ngx-bootstrap ??? confirm-popup.component.ts
helper.service.ts
sign-in.component.ts
"Confirmation" and "How to pass data to modal?" not show in modal. How to show...??? |
on Parent component
constructor(public dialogRef: DialogRef){ |
@tranminhphong0108 I don't understand your example of the modal service. Your helper.service.ts has two parameters The examples on https://valor-software.com/ngx-bootstrap/#/modals have the same problem. |
@MgSam did you find any solution for this problem? |
pass data with initialState params
note: there would be |
How does this help me receive information back from the calling component? I'm looking for an example of where a modal is called from one component, performs an operation (like add an item) and then the calling component is informed of the add and can then perform operations as needed. Seems like something that is a quite common need. |
here is how you send information back to parent component ( calling component)
here key
hope it will help |
@zymr-keshav Awesome. That should really be part of the official docs. |
How does the component receive the parameters? |
set for eg:
in confirmPopupComponent
|
Sorry, but I have exactly the same issue, and its not clear at all from the docs, (or above how one uses the initial state property in the component that is passed to the Dialog show event. I pass in an object with properties I need (initialState) along with my component I wish to show. However, there is nothing I can do to reference anything in that component from initial state. I still cant figure it out from your solutions above either. |
you can pass any data from initialState property only, that is fixed name of the property. |
Yes, this is what the docs say, but even in the example given with the documentation, initialState or any named property of initialState is always null. |
I think the handling of modals in ngx-bootstrap could be much improved ... i understand that i can put my own eventemitters on my modal component to signal return values, but what about when the user exits the dialog via the ESC key of by clicking outside of the dialog bounds? I then have to combine my custom eventemitters with those exposed on the BsModalService. I think it would make more sense if the OnShow/OnShown/... events were put on the BsModalRef instead of the global service ... |
To help with the issue of pressing the ESC key or clicking outside the dialog box and still receiving a result, I wrote a question/answer on StackOverflow with code that handles it. It's explained there, so I won't repost it here, check it out: |
|
@marcosdimitrio Your answer is perfect, thanks. But how should I return a Boolean instead of string to use it in my canDeactivate guard function? Any Idea? |
currently returning a boolean actually, check |
Thanks a lot, Its worked for me |
I am assigning the end result of events model at this.data and recieving data to its parent listing component by subscribing the modelService.onHide event. I am creating an event in addEvents model.
|
passing data to the component is fine. The real problem people are looking for is receiving data back from the modalComponent |
Couldn't you use the initialState to create a callback method. Similar how it's done here. |
In your Service, create this function
then in your demo-modal.component.ts create an EventEmitter
|
Thank you very much for your code, I tried it and returned the following error:
It seems that the Error is caused by an asynchronous call(toPromise),I must get the result of Finally, I used the following code above, it works for me, but I still wonder why the above code go wrong?thank you very much!
|
What is this.modalConfig ? or how to set value of this.modalConfig ? |
This works, but remove |
What do we use .show(ConfirmPopupComponent,...), what is the use of this ConfirmPopupComponent ?? |
Does anyone know how I can pass initialData and access it if using a template instead of a component? |
No description provided.
The text was updated successfully, but these errors were encountered: