diff --git a/src/component-loader/component-loader.class.ts b/src/component-loader/component-loader.class.ts index db094b7a17..02573a365d 100644 --- a/src/component-loader/component-loader.class.ts +++ b/src/component-loader/component-loader.class.ts @@ -104,13 +104,13 @@ export class ComponentLoader { } // todo: appendChild to element or document.querySelector(this.container) - public show(opts: { content?: string | TemplateRef, [key: string]: any } = {}): ComponentRef { + public show(opts: { content?: string | TemplateRef, context?: any, [key: string]: any } = {}): ComponentRef { this._subscribePositioning(); this._innerComponent = null; if (!this._componentRef) { this.onBeforeShow.emit(); - this._contentRef = this._getContentRef(opts.content); + this._contentRef = this._getContentRef(opts.content, opts.context); const injector = ReflectiveInjector.resolveAndCreate(this._providers, this._injector); this._componentRef = this._componentFactory.create(injector, this._contentRef.nodes); @@ -289,14 +289,15 @@ export class ComponentLoader { this._zoneSubscription = null; } - private _getContentRef(content: string | TemplateRef | any): ContentRef { + private _getContentRef(content: string | TemplateRef | any, context?: any): ContentRef { if (!content) { return new ContentRef([]); } if (content instanceof TemplateRef) { if (this._viewContainerRef) { - const viewRef = this._viewContainerRef.createEmbeddedView>(content); + const viewRef = this._viewContainerRef.createEmbeddedView>(content, context); + viewRef.markForCheck(); return new ContentRef([viewRef.rootNodes], viewRef); } const viewRef = content.createEmbeddedView({}); diff --git a/src/popover/popover.directive.ts b/src/popover/popover.directive.ts index 1be1120f95..d14c4efd2f 100644 --- a/src/popover/popover.directive.ts +++ b/src/popover/popover.directive.ts @@ -15,6 +15,10 @@ export class PopoverDirective implements OnInit, OnDestroy { * Content to be displayed as popover. */ @Input() public popover: string | TemplateRef; + /** + * Context to be used if popover is a template. + */ + @Input() public popoverContext: any; /** * Title of a popover. */ @@ -103,6 +107,7 @@ export class PopoverDirective implements OnInit, OnDestroy { .position({attachment: this.placement}) .show({ content: this.popover, + context: this.popoverContext, placement: this.placement, title: this.popoverTitle, containerClass: this.containerClass