You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+64-32Lines changed: 64 additions & 32 deletions
Original file line number
Diff line number
Diff line change
@@ -28,6 +28,8 @@ Modal dialog uses `ComponentFactoryResolver` to inject the given child component
28
28
[ModalDialogService](#modaldialogservice) makes sure that only one instance of a modal dialog is opened at a time.
29
29
With [IModalDialogOptions](#imodaldialogoptions) you can define which component will be rendered inside the dialog and configure it based on your needs.
30
30
31
+
You can further use action buttons to control modal dialog from external component or child component. If action performed on button click is successful, modal dialog will close. Otherwise it will alert user.
32
+
31
33
## Styles and visuals
32
34
33
35
`Ngx-modal-dialog` is intended to be used with Bootstrap 4, however you can apply your custom styles from your desired UI framework by providing class names in [IModalDialogSettings](#imodaldialogsettings).
@@ -61,6 +63,26 @@ openNewDialog() {
61
63
});
62
64
}
63
65
```
66
+
4. Arbitrary define `actionButtons` in modal dialog options or child component to control modal dialog.
67
+
68
+
```ts
69
+
classMyModalComponentimplementsIModalDialog {
70
+
actionButtons:IModalDialogButton[];
71
+
72
+
constructor() {
73
+
this.actionButtons= [
74
+
{ text: 'Close' }, // no special processing here
75
+
{ text: 'I will always close', onAction: () =>true },
Every component that is used as modal dialog must implement `IModalDialog`.
72
94
#### Methods:
73
-
-`dialogInit(reference: ComponentRef<IModalDialog>, options?: IModalDialogOptions) => void`: This method is called after initialization of child component. Purpose of the method is to pass necessary information from outer scope to child component.
This method is called after initialization of child component. Purpose of the method is to pass necessary information from outer scope to child component.
ReturnType: `Promise<any>` or `Observable<any>` or `boolean`
106
137
Function to be called on close button click. In case of Promise and Observable, modal dialog will not close unless successful resolve happens. In case of boolean, modal dialog will close only if result is `truthful`.
107
138
108
-
##### actionButtons
139
+
-`actionButtons`
109
140
Mandatory: `false`
110
141
Default: -
111
-
Type: `Array of IModalDialogButton`
142
+
Type: `Array<IModalDialogButton>`
112
143
Footer action buttons for control of modal dialog. See [IModalDialogButton](#imodaldialogbutton).
144
+
Action buttons defined in child component have priority over action buttons defined via options.
113
145
114
-
##### data
146
+
-`data`
115
147
Mandatory: `false`
116
148
Default: -
117
149
Type: -
118
150
Arbitrary data that will be passed to child component via `dialogInit` method.
119
151
120
-
##### settings
152
+
-`settings`
121
153
Mandatory: `false`
122
154
Default: -
123
155
Type: `IModalDialogSettings`
124
156
Additional settings for granular configuration of modal dialog. See [IModalDialogSettings](#imodaldialogsettings).
0 commit comments