66 * found in the LICENSE file at https://angular.io/license
77 */
88
9- import { TemplateRef , ViewContainerRef , ElementRef , ComponentRef , EmbeddedViewRef , Injector , ComponentFactoryResolver } from '@angular/core' ;
9+ import { TemplateRef , ViewContainerRef , ElementRef , ComponentRef , EmbeddedViewRef , Injector , Binding , Type , DirectiveWithBindings } from '@angular/core' ;
1010import { View } from '@nativescript/core' ;
1111import { throwNullPortalOutletError , throwPortalAlreadyAttachedError , throwNoPortalAttachedError , throwNullPortalError , throwPortalOutletAlreadyDisposedError , throwUnknownPortalTypeError } from './portal-errors' ;
1212import type { ComponentType } from '../../utils/general' ;
@@ -16,7 +16,7 @@ import type { ComponentType } from '../../utils/general';
1616 * It can be attach to / detached from a `PortalOutlet`.
1717 */
1818export abstract class Portal < T > {
19- private _attachedHost : PortalOutlet | null ;
19+ private _attachedHost : PortalOutlet | null = null ;
2020
2121 /** Attach this portal to a host. */
2222 attach ( host : PortalOutlet ) : T {
@@ -68,27 +68,45 @@ export class ComponentPortal<T> extends Portal<ComponentRef<T>> {
6868 component : ComponentType < T > ;
6969
7070 /**
71- * [Optional] Where the attached component should live in Angular's *logical* component tree.
71+ * Where the attached component should live in Angular's *logical* component tree.
7272 * This is different from where the component *renders*, which is determined by the PortalOutlet.
7373 * The origin is necessary when the host is outside of the Angular application context.
7474 */
7575 viewContainerRef ?: ViewContainerRef | null ;
7676
77- /** [Optional] Injector used for the instantiation of the component. */
77+ /** Injector used for the instantiation of the component. */
7878 injector ?: Injector | null ;
7979
8080 /**
81- * Alternate `ComponentFactoryResolver` to use when resolving the associated component.
82- * Defaults to using the resolver from the outlet that the portal is attached to.
81+ * List of NativeScript views that should be projected through `<ng-content>` of the attached component.
8382 */
84- componentFactoryResolver ?: ComponentFactoryResolver | null ;
83+ projectableNodes ?: View [ ] [ ] | null ;
8584
86- constructor ( component : ComponentType < T > , viewContainerRef ?: ViewContainerRef | null , injector ?: Injector | null , componentFactoryResolver ?: ComponentFactoryResolver | null ) {
85+ /**
86+ * Bindings to apply to the created component.
87+ */
88+ readonly bindings : Binding [ ] | null ;
89+
90+ /**
91+ * Directives to apply to the created component.
92+ */
93+ readonly directives : ( Type < unknown > | DirectiveWithBindings < unknown > ) [ ] | null ;
94+
95+ constructor (
96+ component : ComponentType < T > ,
97+ viewContainerRef ?: ViewContainerRef | null ,
98+ injector ?: Injector | null ,
99+ projectableNodes ?: View [ ] [ ] | null ,
100+ bindings ?: Binding [ ] ,
101+ directives ?: ( Type < unknown > | DirectiveWithBindings < unknown > ) [ ] ,
102+ ) {
87103 super ( ) ;
88104 this . component = component ;
89105 this . viewContainerRef = viewContainerRef ;
90106 this . injector = injector ;
91- this . componentFactoryResolver = componentFactoryResolver ;
107+ this . projectableNodes = projectableNodes ;
108+ this . bindings = bindings || null ;
109+ this . directives = directives || null ;
92110 }
93111}
94112
@@ -105,11 +123,15 @@ export class TemplatePortal<C = any> extends Portal<EmbeddedViewRef<C>> {
105123 /** Contextual data to be passed in to the embedded view. */
106124 context : C | undefined ;
107125
108- constructor ( template : TemplateRef < C > , viewContainerRef : ViewContainerRef , context ?: C ) {
126+ /** The injector to use for the embedded view. */
127+ injector : Injector | undefined ;
128+
129+ constructor ( template : TemplateRef < C > , viewContainerRef : ViewContainerRef , context ?: C , injector ?: Injector ) {
109130 super ( ) ;
110131 this . templateRef = template ;
111132 this . viewContainerRef = viewContainerRef ;
112133 this . context = context ;
134+ this . injector = injector ;
113135 }
114136
115137 get origin ( ) : ElementRef {
@@ -168,13 +190,13 @@ export interface PortalOutlet {
168190 */
169191export abstract class BasePortalOutlet implements PortalOutlet {
170192 /** The portal currently attached to the host. */
171- protected _attachedPortal : Portal < any > | null ;
193+ protected _attachedPortal : Portal < any > | null = null ;
172194
173195 /** A function that will permanently dispose this host. */
174- private _disposeFn : ( ( ) => void ) | null ;
196+ private _disposeFn : ( ( ) => void ) | null = null ;
175197
176198 /** Whether this host has already been permanently disposed. */
177- private _isDisposed = false ;
199+ private _isDisposed : boolean = false ;
178200
179201 /** Whether this host has an attached portal. */
180202 hasAttached ( ) : boolean {
0 commit comments