ng2-bootstrap-modal icon indicating copy to clipboard operation
ng2-bootstrap-modal copied to clipboard

How to return model from Modal?

Open kahanu opened this issue 7 years ago • 1 comments

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.

kahanu avatar Jul 28 '17 19:07 kahanu

My workaround might be a little hacky, but here is how I did it:

prompt.component.ts

  1. Line 27: Change the return type of the DialogComponent to <PromptModel, any>
  2. 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.

xLarry avatar Jul 31 '17 16:07 xLarry