1
1
import {
2
- Attribute ,
3
2
ChangeDetectorRef ,
4
3
ComponentFactory ,
5
4
ComponentFactoryResolver ,
@@ -9,14 +8,14 @@ import {
9
8
ElementRef ,
10
9
EnvironmentInjector ,
11
10
EventEmitter ,
12
- Inject ,
11
+ HostAttributeToken ,
12
+ inject ,
13
13
InjectionToken ,
14
14
InjectOptions ,
15
15
Injector ,
16
16
NgZone ,
17
17
OnDestroy ,
18
18
Output ,
19
- SkipSelf ,
20
19
Type ,
21
20
ViewContainerRef ,
22
21
} from '@angular/core' ;
@@ -88,14 +87,8 @@ export class DestructibleInjector implements Injector {
88
87
const ref = this . parent . get ( token , notFoundValue , flags ) ;
89
88
90
89
// if we're skipping ourselves then it's not our responsibility to destroy
91
- if ( typeof flags === 'number' ) {
92
- if ( ! ( flags && this . destructibleProviders . has ( token ) ) ) {
93
- this . refs . add ( ref ) ;
94
- }
95
- } else {
96
- if ( ! flags ?. skipSelf && this . destructibleProviders . has ( token ) ) {
97
- this . refs . add ( ref ) ;
98
- }
90
+ if ( ! flags ?. skipSelf && this . destructibleProviders . has ( token ) ) {
91
+ this . refs . add ( ref ) ;
99
92
}
100
93
101
94
return ref ;
@@ -123,6 +116,17 @@ registerElement('page-router-outlet', () => Frame);
123
116
standalone : true ,
124
117
} ) // tslint:disable-line:directive-selector
125
118
export class PageRouterOutlet implements OnDestroy , RouterOutletContract {
119
+ private parentContexts = inject ( ChildrenOutletContexts ) ;
120
+ private location = inject ( ViewContainerRef ) ;
121
+ private locationStrategy = inject ( NSLocationStrategy ) ;
122
+ private resolver = inject ( ComponentFactoryResolver ) ;
123
+ private changeDetector = inject ( ChangeDetectorRef ) ;
124
+ private pageFactory = inject < PageFactory > ( PAGE_FACTORY ) ;
125
+ private routeReuseStrategy = inject ( NSRouteReuseStrategy ) ;
126
+ private ngZone = inject ( NgZone ) ;
127
+ private router = inject ( Router ) ;
128
+ private environmentInjector = inject ( EnvironmentInjector ) ;
129
+
126
130
// tslint:disable-line:directive-class-suffix
127
131
private activated : ComponentRef < any > | null = null ;
128
132
private _activatedRoute : ActivatedRoute | null = null ;
@@ -146,15 +150,6 @@ export class PageRouterOutlet implements OnDestroy, RouterOutletContract {
146
150
// eslint-disable-next-line @angular-eslint/no-output-rename
147
151
@Output ( 'deactivate' ) deactivateEvents = new EventEmitter < any > ( ) ; // tslint:disable-line:no-output-rename
148
152
149
- /** @deprecated from Angular since v4 */
150
- get locationInjector ( ) : Injector {
151
- return this . location . injector ;
152
- }
153
- /** @deprecated from Angular since v4 */
154
- get locationFactoryResolver ( ) : ComponentFactoryResolver {
155
- return this . resolver ;
156
- }
157
-
158
153
get isActivated ( ) : boolean {
159
154
return ! ! this . activated ;
160
155
}
@@ -187,24 +182,15 @@ export class PageRouterOutlet implements OnDestroy, RouterOutletContract {
187
182
return { } ;
188
183
}
189
184
190
- constructor (
191
- private parentContexts : ChildrenOutletContexts ,
192
- private location : ViewContainerRef ,
193
- @Attribute ( 'name' ) name : string ,
194
- @Attribute ( 'actionBarVisibility' ) actionBarVisibility : string ,
195
- @Attribute ( 'isEmptyOutlet' ) isEmptyOutlet : boolean ,
196
- private locationStrategy : NSLocationStrategy ,
197
- private componentFactoryResolver : ComponentFactoryResolver ,
198
- private resolver : ComponentFactoryResolver ,
199
- private changeDetector : ChangeDetectorRef ,
200
- @Inject ( PAGE_FACTORY ) private pageFactory : PageFactory ,
201
- private routeReuseStrategy : NSRouteReuseStrategy ,
202
- private ngZone : NgZone ,
203
- private router : Router ,
204
- elRef : ElementRef ,
205
- viewUtil : ViewUtil ,
206
- private environmentInjector : EnvironmentInjector ,
207
- ) {
185
+ constructor ( ) {
186
+ const parentContexts = this . parentContexts ;
187
+ const name = inject ( new HostAttributeToken ( 'name' ) , { optional : true } ) ;
188
+ const actionBarVisibility = inject ( new HostAttributeToken ( 'actionBarVisibility' ) , { optional : true } ) ;
189
+ const isEmptyOutlet = ! ! inject ( new HostAttributeToken ( 'isEmptyOutlet' ) , { optional : true } ) ;
190
+ const resolver = this . resolver ;
191
+ const elRef = inject ( ElementRef ) ;
192
+ const viewUtil = inject ( ViewUtil ) ;
193
+
208
194
this . isEmptyOutlet = isEmptyOutlet ;
209
195
this . frame = elRef . nativeElement ;
210
196
this . setActionBarVisibility ( actionBarVisibility ) ;
0 commit comments