File tree Expand file tree Collapse file tree 4 files changed +22
-4
lines changed
tools/public_api_guard/material Expand file tree Collapse file tree 4 files changed +22
-4
lines changed Original file line number Diff line number Diff line change 66 * found in the LICENSE file at https://angular.io/license
77 */
88
9- import { ViewContainerRef } from '@angular/core' ;
9+ import { ViewContainerRef , ComponentFactoryResolver } from '@angular/core' ;
1010import { Direction } from '@angular/cdk/bidi' ;
1111import { ScrollStrategy } from '@angular/cdk/overlay' ;
1212
@@ -114,5 +114,8 @@ export class MatDialogConfig<D = any> {
114114 */
115115 closeOnNavigation ?: boolean = true ;
116116
117+ /** Alternate `ComponentFactoryResolver` to use when resolving the associated component. */
118+ componentFactoryResolver ?: ComponentFactoryResolver ;
119+
117120 // TODO(jelbourn): add configuration for lifecycle hooks, ARIA labelling.
118121}
Original file line number Diff line number Diff line change @@ -16,7 +16,8 @@ import {
1616 NgModule ,
1717 TemplateRef ,
1818 ViewChild ,
19- ViewContainerRef
19+ ViewContainerRef ,
20+ ComponentFactoryResolver
2021} from '@angular/core' ;
2122import { By } from '@angular/platform-browser' ;
2223import { NoopAnimationsModule } from '@angular/platform-browser/animations' ;
@@ -741,6 +742,19 @@ describe('MatDialog', () => {
741742 expect ( scrollStrategy . enable ) . toHaveBeenCalled ( ) ;
742743 } ) ) ;
743744
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+
744758 describe ( 'passing in data' , ( ) => {
745759 it ( 'should be able to pass in data' , ( ) => {
746760 let config = {
Original file line number Diff line number Diff line change @@ -223,8 +223,8 @@ export class MatDialog implements OnDestroy {
223223 const injector = new PortalInjector ( userInjector || this . _injector , new WeakMap ( [
224224 [ MatDialogConfig , config ]
225225 ] ) ) ;
226- const containerPortal =
227- new ComponentPortal ( MatDialogContainer , config . viewContainerRef , injector ) ;
226+ const containerPortal = new ComponentPortal ( MatDialogContainer ,
227+ config . viewContainerRef , injector , config . componentFactoryResolver ) ;
228228 const containerRef = overlay . attach < MatDialogContainer > ( containerPortal ) ;
229229
230230 return containerRef . instance ;
Original file line number Diff line number Diff line change @@ -61,6 +61,7 @@ export declare class MatDialogConfig<D = any> {
6161 autoFocus ?: boolean ;
6262 backdropClass ?: string ;
6363 closeOnNavigation ?: boolean ;
64+ componentFactoryResolver ?: ComponentFactoryResolver ;
6465 data ?: D | null ;
6566 direction ?: Direction ;
6667 disableClose ?: boolean ;
You can’t perform that action at this time.
0 commit comments