|
1 | | -import { Attribute, ChangeDetectorRef, ComponentFactory, ComponentFactoryResolver, ComponentRef, Directive, Inject, InjectionToken, Injector, OnDestroy, EventEmitter, Output, Type, ViewContainerRef, ElementRef, InjectFlags, NgZone, EnvironmentInjector, inject } from '@angular/core'; |
| 1 | +import { Attribute, ChangeDetectorRef, ComponentFactory, ComponentFactoryResolver, ComponentRef, Directive, Inject, InjectionToken, Injector, OnDestroy, EventEmitter, Output, Type, ViewContainerRef, ElementRef, InjectFlags, NgZone, EnvironmentInjector, inject, InjectOptions } from '@angular/core'; |
2 | 2 | import { ActivatedRoute, ActivatedRouteSnapshot, ChildrenOutletContexts, Data, PRIMARY_OUTLET, Router, RouterOutletContract } from '@angular/router'; |
3 | 3 |
|
4 | 4 | import { Frame, Page, NavigatedData, profile, NavigationEntry } from '@nativescript/core'; |
@@ -32,12 +32,20 @@ function isComponentFactoryResolver(item: any): item is ComponentFactoryResolver |
32 | 32 | export class DestructibleInjector implements Injector { |
33 | 33 | private refs = new Set<any>(); |
34 | 34 | constructor(private destructibleProviders: ProviderSet, private parent: Injector) {} |
35 | | - get<T>(token: Type<T> | InjectionToken<T>, notFoundValue?: T, flags?: InjectFlags): T { |
| 35 | + get<T>(token: Type<T> | InjectionToken<T>, notFoundValue?: T, flags?: InjectOptions | InjectFlags): T { |
36 | 36 | const ref = this.parent.get(token, notFoundValue, flags); |
| 37 | + |
37 | 38 | // if we're skipping ourselves then it's not our responsibility to destroy |
38 | | - if (!(flags & InjectFlags.SkipSelf) && this.destructibleProviders.has(token)) { |
39 | | - this.refs.add(ref); |
| 39 | + if (typeof flags === 'number') { |
| 40 | + if (!(flags & InjectFlags.SkipSelf) && this.destructibleProviders.has(token)) { |
| 41 | + this.refs.add(ref); |
| 42 | + } |
| 43 | + } else { |
| 44 | + if (!flags?.skipSelf && this.destructibleProviders.has(token)) { |
| 45 | + this.refs.add(ref); |
| 46 | + } |
40 | 47 | } |
| 48 | + |
41 | 49 | return ref; |
42 | 50 | } |
43 | 51 | destroy() { |
@@ -71,7 +79,6 @@ export class PageRouterOutlet implements OnDestroy, RouterOutletContract { |
71 | 79 | private isEmptyOutlet: boolean; |
72 | 80 | private viewUtil: ViewUtil; |
73 | 81 | private frame: Frame; |
74 | | - private router = inject(Router); |
75 | 82 |
|
76 | 83 | attachEvents: EventEmitter<unknown> = new EventEmitter(); |
77 | 84 | detachEvents: EventEmitter<unknown> = new EventEmitter(); |
|
0 commit comments