Skip to content

Commit 0767edf

Browse files
committed
feat(component-loader): simplified show method usage
1 parent ea1de3c commit 0767edf

File tree

5 files changed

+9
-7
lines changed

5 files changed

+9
-7
lines changed

src/component-loader/component-loader.class.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,18 +111,18 @@ export class ComponentLoader<T> {
111111
return this;
112112
}
113113

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

117117
if (!this._componentRef) {
118118
this.onBeforeShow.emit();
119-
this._contentRef = this._getContentRef(content);
119+
this._contentRef = this._getContentRef(opts.content);
120120
const injector = ReflectiveInjector.resolveAndCreate(this._providers, this._injector);
121121
this._componentRef = this._viewContainerRef
122122
.createComponent(this._componentFactory, 0, injector, this._contentRef.nodes);
123123
this.instance = this._componentRef.instance;
124124

125-
Object.assign(this._componentRef.instance, mixin || {});
125+
Object.assign(this._componentRef.instance, opts);
126126

127127
if (this.container === 'body' && typeof document !== 'undefined') {
128128
document.querySelector(this.container as string)

src/modal/modal.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ export class ModalDirective implements AfterViewInit, OnDestroy {
229229
this._backdrop
230230
.attach(ModalBackdropComponent)
231231
.to('body')
232-
.show(null, {isAnimated: false});
232+
.show({isAnimated: false});
233233
this.backdrop = this._backdrop._componentRef;
234234

235235
if (this.isAnimated) {

src/popover/popover.directive.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@ export class PopoverDirective implements OnInit, OnDestroy {
8181
.attach(PopoverContainerComponent)
8282
.to(this.container)
8383
.position({attachment: this.placement})
84-
.show(this.popover, {
84+
.show({
85+
content: this.popover,
8586
placement: this.placement,
8687
title: this.popoverTitle
8788
});

src/tooltip/tooltip.directive.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,8 @@ export class TooltipDirective implements OnInit, OnDestroy {
180180
.attach(TooltipContainerComponent)
181181
.to(this.container)
182182
.position({attachment: this.placement})
183-
.show(this.tooltip, {
183+
.show({
184+
content: this.tooltip,
184185
placement: this.placement,
185186
title: this.tooltipTitle
186187
});

src/typeahead/typeahead.directive.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ export class TypeaheadDirective implements OnInit, OnDestroy {
199199
// todo: add append to body, after updating positioning service
200200
// .to(this.container)
201201
// .position({attachment: 'bottom left'})
202-
.show(null, {
202+
.show({
203203
typeaheadRef: this,
204204
placement: this.placement,
205205
animation: false

0 commit comments

Comments
 (0)