@@ -10,13 +10,13 @@ import {
10
10
Type ,
11
11
ViewRef ,
12
12
} from '@angular/core' ;
13
- import { BehaviorSubject , startWith , Subject } from 'rxjs' ;
13
+ import { BehaviorSubject , Subject } from 'rxjs' ;
14
14
import { DialogRef , InternalDialogRef } from './dialog-ref' ;
15
15
import { DialogComponent } from './dialog.component' ;
16
16
import { DragOffset } from './draggable.directive' ;
17
17
import { DIALOG_CONFIG , DIALOG_DOCUMENT_REF , GLOBAL_DIALOG_CONFIG , NODES_TO_INSERT } from './providers' ;
18
18
import { AttachOptions , DialogConfig , ExtractData , ExtractResult , GlobalDialogConfig , OpenParams } from './types' ;
19
- import { map } from 'rxjs/operators ' ;
19
+ import { isDialogWithConfig } from './dialog.utils ' ;
20
20
21
21
const OVERFLOW_HIDDEN_CLASS = 'ngneat-dialog-hidden' ;
22
22
@@ -56,8 +56,9 @@ export class DialogService {
56
56
component : C ,
57
57
config ?: Partial < DialogConfig < ExtractData < InstanceType < C > > > >
58
58
) : DialogRef < ExtractData < InstanceType < C > > , ExtractResult < InstanceType < C > > > ;
59
- open ( componentOrTemplate : any , config : Partial < DialogConfig < any > > = { } ) : DialogRef {
60
- const mergedConfig = this . mergeConfig ( config ) ;
59
+ open ( componentOrTemplate : Type < unknown > | any , config : Partial < DialogConfig < any > > = { } ) : DialogRef {
60
+ const componentConfig = isDialogWithConfig ( componentOrTemplate ) ? componentOrTemplate . getModalConfig ( ) : { } ;
61
+ const mergedConfig = this . mergeConfig ( config , componentConfig ) ;
61
62
mergedConfig . onOpen ?.( ) ;
62
63
63
64
const dialogRef = new InternalDialogRef ( {
@@ -216,11 +217,15 @@ export class DialogService {
216
217
} ) ;
217
218
}
218
219
219
- private mergeConfig ( inlineConfig : Partial < DialogConfig > ) : DialogConfig & GlobalDialogConfig {
220
+ private mergeConfig (
221
+ inlineConfig : Partial < DialogConfig > ,
222
+ componentBasedConfig : Partial < DialogConfig >
223
+ ) : DialogConfig & GlobalDialogConfig {
220
224
return {
221
225
...this . globalConfig ,
222
226
id : nanoid ( ) ,
223
227
...inlineConfig ,
228
+ ...componentBasedConfig ,
224
229
sizes : this . globalConfig ?. sizes ,
225
230
} as DialogConfig & GlobalDialogConfig ;
226
231
}
0 commit comments