ng2-bootstrap-modal
ng2-bootstrap-modal copied to clipboard
How to return model from Modal?
I want to pass a model containing properties of data to the dialog content, and then return the model back with any changes to the data. An example scenario would be the dialog open a form with fields, the user edits the content in the fields, and save the the dialog.
I want my host component to capture that model with all the properties. I would rather not have to create properties for all of the model properties, which could be 20 properties.
Is this possible? If so, how? It's not obvious from your examples.
My workaround might be a little hacky, but here is how I did it:
-
Line 27: Change the return type of the DialogComponent to
<PromptModel, any>
-
Line 35: Attach your return data to
this.result
app.component.ts
3. Line 37-40: Rename the parameter message
to something more speaking (e.g. result
) and access the data.
Let me know if I missed something.