File tree 4 files changed +22
-4
lines changed
tools/public_api_guard/material
4 files changed +22
-4
lines changed Original file line number Diff line number Diff line change 6
6
* found in the LICENSE file at https://angular.io/license
7
7
*/
8
8
9
- import { ViewContainerRef } from '@angular/core' ;
9
+ import { ViewContainerRef , ComponentFactoryResolver } from '@angular/core' ;
10
10
import { Direction } from '@angular/cdk/bidi' ;
11
11
import { ScrollStrategy } from '@angular/cdk/overlay' ;
12
12
@@ -114,5 +114,8 @@ export class MatDialogConfig<D = any> {
114
114
*/
115
115
closeOnNavigation ?: boolean = true ;
116
116
117
+ /** Alternate `ComponentFactoryResolver` to use when resolving the associated component. */
118
+ componentFactoryResolver ?: ComponentFactoryResolver ;
119
+
117
120
// TODO(jelbourn): add configuration for lifecycle hooks, ARIA labelling.
118
121
}
Original file line number Diff line number Diff line change @@ -16,7 +16,8 @@ import {
16
16
NgModule ,
17
17
TemplateRef ,
18
18
ViewChild ,
19
- ViewContainerRef
19
+ ViewContainerRef ,
20
+ ComponentFactoryResolver
20
21
} from '@angular/core' ;
21
22
import { By } from '@angular/platform-browser' ;
22
23
import { NoopAnimationsModule } from '@angular/platform-browser/animations' ;
@@ -741,6 +742,19 @@ describe('MatDialog', () => {
741
742
expect ( scrollStrategy . enable ) . toHaveBeenCalled ( ) ;
742
743
} ) ) ;
743
744
745
+ it ( 'should be able to pass in an alternate ComponentFactoryResolver' ,
746
+ inject ( [ ComponentFactoryResolver ] , ( resolver : ComponentFactoryResolver ) => {
747
+ spyOn ( resolver , 'resolveComponentFactory' ) . and . callThrough ( ) ;
748
+
749
+ dialog . open ( PizzaMsg , {
750
+ viewContainerRef : testViewContainerRef ,
751
+ componentFactoryResolver : resolver
752
+ } ) ;
753
+ viewContainerFixture . detectChanges ( ) ;
754
+
755
+ expect ( resolver . resolveComponentFactory ) . toHaveBeenCalled ( ) ;
756
+ } ) ) ;
757
+
744
758
describe ( 'passing in data' , ( ) => {
745
759
it ( 'should be able to pass in data' , ( ) => {
746
760
let config = {
Original file line number Diff line number Diff line change @@ -223,8 +223,8 @@ export class MatDialog implements OnDestroy {
223
223
const injector = new PortalInjector ( userInjector || this . _injector , new WeakMap ( [
224
224
[ MatDialogConfig , config ]
225
225
] ) ) ;
226
- const containerPortal =
227
- new ComponentPortal ( MatDialogContainer , config . viewContainerRef , injector ) ;
226
+ const containerPortal = new ComponentPortal ( MatDialogContainer ,
227
+ config . viewContainerRef , injector , config . componentFactoryResolver ) ;
228
228
const containerRef = overlay . attach < MatDialogContainer > ( containerPortal ) ;
229
229
230
230
return containerRef . instance ;
Original file line number Diff line number Diff line change @@ -61,6 +61,7 @@ export declare class MatDialogConfig<D = any> {
61
61
autoFocus ?: boolean ;
62
62
backdropClass ?: string ;
63
63
closeOnNavigation ?: boolean ;
64
+ componentFactoryResolver ?: ComponentFactoryResolver ;
64
65
data ?: D | null ;
65
66
direction ?: Direction ;
66
67
disableClose ?: boolean ;
You can’t perform that action at this time.
0 commit comments