Skip to content

Commit

Permalink
feat(component-loader): simplified show method usage
Browse files Browse the repository at this point in the history
  • Loading branch information
valorkin committed Dec 15, 2016
1 parent ea1de3c commit 0767edf
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 7 deletions.
6 changes: 3 additions & 3 deletions src/component-loader/component-loader.class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,18 +111,18 @@ export class ComponentLoader<T> {
return this;
}

public show(content?: string | TemplateRef<any>, mixin?: any): ComponentRef<T> {
public show(opts: {content?: string | TemplateRef<any>, [key:string]: any} = {}): ComponentRef<T> {
this._subscribePositioning();

if (!this._componentRef) {
this.onBeforeShow.emit();
this._contentRef = this._getContentRef(content);
this._contentRef = this._getContentRef(opts.content);
const injector = ReflectiveInjector.resolveAndCreate(this._providers, this._injector);
this._componentRef = this._viewContainerRef
.createComponent(this._componentFactory, 0, injector, this._contentRef.nodes);
this.instance = this._componentRef.instance;

Object.assign(this._componentRef.instance, mixin || {});
Object.assign(this._componentRef.instance, opts);

if (this.container === 'body' && typeof document !== 'undefined') {
document.querySelector(this.container as string)
Expand Down
2 changes: 1 addition & 1 deletion src/modal/modal.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ export class ModalDirective implements AfterViewInit, OnDestroy {
this._backdrop
.attach(ModalBackdropComponent)
.to('body')
.show(null, {isAnimated: false});
.show({isAnimated: false});
this.backdrop = this._backdrop._componentRef;

if (this.isAnimated) {
Expand Down
3 changes: 2 additions & 1 deletion src/popover/popover.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ export class PopoverDirective implements OnInit, OnDestroy {
.attach(PopoverContainerComponent)
.to(this.container)
.position({attachment: this.placement})
.show(this.popover, {
.show({
content: this.popover,
placement: this.placement,
title: this.popoverTitle
});
Expand Down
3 changes: 2 additions & 1 deletion src/tooltip/tooltip.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,8 @@ export class TooltipDirective implements OnInit, OnDestroy {
.attach(TooltipContainerComponent)
.to(this.container)
.position({attachment: this.placement})
.show(this.tooltip, {
.show({
content: this.tooltip,
placement: this.placement,
title: this.tooltipTitle
});
Expand Down
2 changes: 1 addition & 1 deletion src/typeahead/typeahead.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ export class TypeaheadDirective implements OnInit, OnDestroy {
// todo: add append to body, after updating positioning service
// .to(this.container)
// .position({attachment: 'bottom left'})
.show(null, {
.show({
typeaheadRef: this,
placement: this.placement,
animation: false
Expand Down

0 comments on commit 0767edf

Please sign in to comment.