Skip to content

Commit 56a7872

Browse files
author
Giuseppe Pennisi
committed
feat: removed deprecated functions
1 parent 637b2a3 commit 56a7872

2 files changed

Lines changed: 8 additions & 22 deletions

File tree

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/angular-winbox/src/lib/winbox.service.ts

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
import {
22
ApplicationRef,
33
ChangeDetectorRef,
4-
ComponentFactoryResolver,
54
ComponentRef,
5+
createComponent,
66
Injectable,
7-
Injector,
87
Type,
98
} from '@angular/core';
10-
import { ComponentPortal, DomPortalOutlet } from '@angular/cdk/portal';
119
import 'winbox';
1210

1311
declare const WinBox: WinBox.WinBoxConstructor;
@@ -25,12 +23,7 @@ export class WinboxService {
2523
private winBoxStack: WinBox[] = [];
2624
public isThereAWinBox = false;
2725

28-
constructor(
29-
private componentFactoryResolver: ComponentFactoryResolver,
30-
private injector: Injector,
31-
private appRef: ApplicationRef
32-
) {}
33-
26+
constructor(private appRef: ApplicationRef) {}
3427
get numberOfWinBoxes(): number {
3528
return this.winBoxStack.length;
3629
}
@@ -41,18 +34,11 @@ export class WinboxService {
4134
): WinBoxContainer<ComponentInstance> {
4235
const winBox = new WinBox(options);
4336

44-
const portalHost = new DomPortalOutlet(
45-
winBox.body,
46-
this.componentFactoryResolver,
47-
this.appRef,
48-
this.injector
49-
);
50-
51-
// Locate the component factory for the HeaderComponent
52-
const portal = new ComponentPortal(component);
53-
54-
// Attach portal to host
55-
const componentRef = portalHost.attach(portal);
37+
const componentRef = createComponent(component, {
38+
environmentInjector: this.appRef.injector,
39+
hostElement: winBox.body,
40+
});
41+
this.appRef.attachView(componentRef.hostView);
5642

5743
// estensione del metodo per permettere all'utente di passare
5844
// una funzione da invocare alla chiusura della winBox

0 commit comments

Comments
 (0)