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IACJ,CAAC;IAVH;QAAC,QAAQ,CAAC;YACR,OAAO,EAAE,CAAC,uBAAuB,EAAE,mBAAmB,CAAC;YACvD,YAAY,EAAE,CAAC,uBAAuB,EAAE,mBAAmB,CAAC;SAC7D,CAAC;;oBAAA;IAQF,mBAAC;AAAD,CAPA,AAOC,IAAA","file":"core/portal/portal-directives.js","sourcesContent":["import {\n NgModule,\n ModuleWithProviders,\n ComponentRef,\n Directive,\n TemplateRef,\n ComponentFactoryResolver,\n ViewContainerRef\n} from '@angular/core';\nimport {Portal, TemplatePortal, ComponentPortal, BasePortalHost} from './portal';\n\n\n/**\n * Directive version of a `TemplatePortal`. Because the directive *is* a TemplatePortal,\n * the directive instance itself can be attached to a host, enabling declarative use of portals.\n *\n * Usage:\n * <template portal #greeting>\n * <p> Hello {{name}} </p>\n * </template>\n */\n@Directive({\n selector: '[portal]',\n exportAs: 'portal',\n})\nexport class TemplatePortalDirective extends TemplatePortal {\n constructor(templateRef: TemplateRef<any>, viewContainerRef: ViewContainerRef) {\n super(templateRef, viewContainerRef);\n }\n}\n\n\n/**\n * Directive version of a PortalHost. Because the directive *is* a PortalHost, portals can be\n * directly attached to it, enabling declarative use.\n *\n * Usage:\n * <template [portalHost]=\"greeting\"></template>\n */\n@Directive({\n selector: '[portalHost]',\n inputs: ['portal: portalHost']\n})\nexport class PortalHostDirective extends BasePortalHost {\n /** The attached portal. */\n private _portal: Portal<any>;\n\n constructor(\n private _componentFactoryResolver: ComponentFactoryResolver,\n private _viewContainerRef: ViewContainerRef) {\n super();\n }\n\n get portal(): Portal<any> {\n return this._portal;\n }\n\n set portal(p: Portal<any>) {\n this._replaceAttachedPortal(p);\n }\n\n /** Attach the given ComponentPortal to this PortlHost using the ComponentFactoryResolver. */\n attachComponentPortal<T>(portal: ComponentPortal<T>): ComponentRef<T> {\n portal.setAttachedHost(this);\n\n // If the portal specifies an origin, use that as the logical location of the component\n // in the application tree. Otherwise use the location of this PortalHost.\n let viewContainerRef = portal.viewContainerRef != null ?\n portal.viewContainerRef :\n this._viewContainerRef;\n\n let componentFactory =\n this._componentFactoryResolver.resolveComponentFactory(portal.component);\n let ref = viewContainerRef.createComponent(\n componentFactory, viewContainerRef.length,\n portal.injector || viewContainerRef.parentInjector);\n\n this.setDisposeFn(() => ref.destroy());\n return ref;\n }\n\n /** Attach the given TemplatePortal to this PortlHost as an embedded View. */\n attachTemplatePortal(portal: TemplatePortal): Map<string, any> {\n portal.setAttachedHost(this);\n\n this._viewContainerRef.createEmbeddedView(portal.templateRef);\n this.setDisposeFn(() => this._viewContainerRef.clear());\n\n // TODO(jelbourn): return locals from view\n return new Map<string, any>();\n }\n\n /** Detatches the currently attached Portal (if there is one) and attaches the given Portal. */\n private _replaceAttachedPortal(p: Portal<any>): void {\n if (this.hasAttached()) {\n this.detach();\n }\n\n if (p) {\n this.attach(p);\n this._portal = p;\n }\n }\n}\n\n\n@NgModule({\n exports: [TemplatePortalDirective, PortalHostDirective],\n declarations: [TemplatePortalDirective, PortalHostDirective],\n})\nexport class PortalModule {\n static forRoot(): ModuleWithProviders {\n return {\n ngModule: PortalModule,\n providers: []\n };\n }\n}\n"],"sourceRoot":"/source/"}
\No newline at end of file