Skip to content

Commit cb06adf

Browse files
author
Srdjan Pajic
committed
updated documentation style, added entryComponents hint
1 parent cb3ca8e commit cb06adf

File tree

1 file changed

+37
-91
lines changed

1 file changed

+37
-91
lines changed

README.md

Lines changed: 37 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ export class AppModule { }
5252
```
5353
2. Create a custom component that implements `IModalDialog` or use the `SimpleModalDialog` as a child component.
5454

55+
Custom component should be inserted into both `declarations` and `entryComponents` in the NgModule they are part of. `entryComponents` has to be used since component is dynamically inserted onto the page and Angular is not aware of it.
56+
5557
3. Inject the `ModalDialogService` where you want to open the dialog. Call `openDialog` passing parent `ViewContainerRef` and `IModalDialogOptions`:
5658
```ts
5759
constructor(modalService: ModalDialogService, viewRef: ViewContainerRef) { }
@@ -68,20 +70,20 @@ openNewDialog() {
6870
```ts
6971
class MyModalComponent implements IModalDialog {
7072
actionButtons: IModalDialogButton[];
71-
73+
7274
constructor() {
7375
this.actionButtons = [
7476
{ text: 'Close' }, // no special processing here
7577
{ text: 'I will always close', onAction: () => true },
7678
{ text: 'I never close', onAction: () => false }
7779
];
7880
}
79-
81+
8082
dialogInit(reference: ComponentRef<IModalDialog>, options?: IModalDialogOptions) {
8183
// no processing needed
8284
}
8385
}
84-
```
86+
```
8587

8688
## API
8789

@@ -92,15 +94,15 @@ class MyModalComponent implements IModalDialog {
9294
### IModalDialog
9395
Every component that is used as modal dialog must implement `IModalDialog`.
9496
#### Methods:
95-
- `dialogInit(reference: ComponentRef<IModalDialog>, options?: IModalDialogOptions) => void`
96-
Mandatory: `true`
97-
Default: -
97+
- `dialogInit(reference: ComponentRef<IModalDialog>, options?: IModalDialogOptions) => void`
98+
Mandatory: `true`
99+
Default: -
98100
This method is called after initialization of child component. Purpose of the method is to pass necessary information from outer scope to child component.
99101
#### Properties:
100-
- `actionButtons`
101-
Mandatory: `false`
102-
Default: -
103-
Type: `string`
102+
- `actionButtons`
103+
Mandatory: `false`
104+
Default: -
105+
Type: `string`
104106
Modal heading text
105107

106108
### IModalDialogOptions
@@ -115,44 +117,24 @@ interface IModalDialogOptions {
115117
settings?: IModalDialogSettings;
116118
}
117119
```
118-
#### Properties:
119-
- `title`
120-
Mandatory: `false`
121-
Default: -
122-
Type: `string`
120+
#### Interface details:
121+
- title: `string`
123122
Modal heading text
124123

125-
- `childComponent`
126-
Mandatory: `false`
127-
Default: -
128-
Type: `any`
124+
- childComponent: `any`
129125
Component type that will be rendered as a content of modal dialog. Component must implement `IModalDialog` interface.
130126

131-
- `onClose()`
132-
Mandatory: `false`
133-
Default: -
134-
Type: `function`
135-
Input: -
136-
ReturnType: `Promise<any>` or `Observable<any>` or `boolean`
127+
- onClose(): `Promise<any>` or `Observable<any>` or `boolean`
137128
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`.
138129

139-
- `actionButtons`
140-
Mandatory: `false`
141-
Default: -
142-
Type: `Array<IModalDialogButton>`
130+
- actionButtons: `Array<IModalDialogButton>`
143131
Footer action buttons for control of modal dialog. See [IModalDialogButton](#imodaldialogbutton).
144132
Action buttons defined in child component have priority over action buttons defined via options.
145133

146-
- `data`
147-
Mandatory: `false`
148-
Default: -
149-
Type: -
134+
- data: `any`
150135
Arbitrary data that will be passed to child component via `dialogInit` method.
151136

152-
- `settings`
153-
Mandatory: `false`
154-
Default: -
155-
Type: `IModalDialogSettings`
137+
- settings: `IModalDialogSettings`
156138
Additional settings for granular configuration of modal dialog. See [IModalDialogSettings](#imodaldialogsettings).
157139

158140
### IModalDialogButton
@@ -164,23 +146,13 @@ interface IModalDialogButton {
164146
onAction?: () => Promise<any> | Observable<any> | boolean;
165147
}
166148
```
167-
#### Properties:
168-
- `text`
169-
Mandatory: `true`
170-
Default: -
171-
Type: `string`
149+
#### Interface details:
150+
- text: `string`
172151
Caption/text on the button
173-
- `buttonClass`
174-
Mandatory: `false`
152+
- buttonClass: `string`
175153
Default: `btn btn-primary`
176-
Type: `string`
177154
Class name of button
178-
- `onAction()`
179-
Mandatory: `false`
180-
Default: -
181-
Type: `function`
182-
Input: -
183-
ReturnType: `Promise<any> | Observable<any> | boolean`
155+
- onAction(): `Promise<any> | Observable<any> | boolean`
184156
Function to be called on 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`.
185157

186158
### IModalDialogSettings
@@ -203,71 +175,45 @@ interface IModalDialogSettings {
203175
}
204176
```
205177

206-
#### Properties:
207-
- `overlayClass`
208-
Mandatory: `false`
178+
#### Interface details:
179+
- overlayClass: `string`
209180
Default: `modal-backdrop fade show`
210-
Type: `string`
211181
Style of the backdrop overlay layer
212-
- `modalClass`
213-
Mandatory: `false`
182+
- modalClass: `string`
214183
Default: `modal fade show`
215-
Type: `string`
216184
Style of modal wrapper
217-
- `contentClass`
218-
Mandatory: `false`
185+
- contentClass: `string`
219186
Default: `modal-content`
220-
Type: `string`
221187
Modal dialog inner content class
222-
- `headerClass`
223-
Mandatory: `false`
188+
- headerClass: `string`
224189
Default: `modal-header`
225-
Type: `string`
226190
Modal dialog header class
227-
- `headerTitleClass`
228-
Mandatory: `false`
191+
- headerTitleClass: `string`
229192
Default: `modal-title`
230-
Type: `string`
231193
Modal dialog header title class
232-
- `closeButtonClass`
233-
Mandatory: `false`
194+
- closeButtonClass: `string`
234195
Default: `close glyphicon glyphicon-remove`
235-
Type: `string`
236196
Modal dialog header close button class
237-
- `closeButtonTitle`
238-
Mandatory: `false`
197+
- closeButtonTitle: `string`
239198
Default: `CLOSE`
240-
Type: `string`
241199
Close button title
242-
- `bodyClass`
243-
Mandatory: `false`
200+
- bodyClass: `string`
244201
Default: `modal-body`
245-
Type: `string`
246202
Modal dialog body class
247-
- `footerClass`
248-
Mandatory: `false`
203+
- footerClass: `string`
249204
Default: `modal-footer`
250-
Type: `string`
251205
Modal dialog footer class
252-
- `alertClass`
253-
Mandatory: `false`
206+
- alertClass: `string`
254207
Default: `shake`
255-
Type: `string`
256208
Style to be appended to dialog once alert happens
257-
- `alertDuration`
258-
Mandatory: `false`
209+
- alertDuration: `number`
259210
Default: `250`
260-
Type: `number`
261211
Duration of alert animation
262-
- `buttonClass`
263-
Mandatory: `false`
212+
- buttonClass: `string`
264213
Default: `btn btn-primary`
265-
Type: `string`
266214
Style of footer action buttons
267-
- `notifyWithAlert`
268-
Mandatory: `false`
215+
- notifyWithAlert: `number`
269216
Default: `true`
270-
Type: `boolean`
271217
Define whether modal should alert user when action fails
272218

273219
## License

0 commit comments

Comments
 (0)