mirror of
https://github.com/angular/angular
synced 2026-05-24 09:28:37 +00:00
refactor(router): Remove use of OutletInjector
OutletInjector doesn't do anything special. Injector.create can be used instead
This commit is contained in:
parent
bd927236df
commit
e288d87742
2 changed files with 7 additions and 22 deletions
|
|
@ -428,9 +428,6 @@
|
|||
{
|
||||
"name": "OuterSubscriber"
|
||||
},
|
||||
{
|
||||
"name": "OutletInjector"
|
||||
},
|
||||
{
|
||||
"name": "PLATFORM_DESTROY_LISTENERS"
|
||||
},
|
||||
|
|
|
|||
|
|
@ -287,7 +287,13 @@ export class RouterOutlet implements OnDestroy, OnInit, RouterOutletContract {
|
|||
const snapshot = activatedRoute._futureSnapshot;
|
||||
const component = snapshot.component!;
|
||||
const childContexts = this.parentContexts.getOrCreateContext(this.name).children;
|
||||
const injector = new OutletInjector(activatedRoute, childContexts, location.injector);
|
||||
const injector = Injector.create({
|
||||
providers: [
|
||||
{provide: ActivatedRoute, useValue: activatedRoute},
|
||||
{provide: ChildrenOutletContexts, useValue: childContexts}
|
||||
],
|
||||
parent: location.injector
|
||||
});
|
||||
|
||||
if (resolverOrInjector && isComponentFactoryResolver(resolverOrInjector)) {
|
||||
const factory = resolverOrInjector.resolveComponentFactory(component);
|
||||
|
|
@ -304,24 +310,6 @@ export class RouterOutlet implements OnDestroy, OnInit, RouterOutletContract {
|
|||
}
|
||||
}
|
||||
|
||||
class OutletInjector implements Injector {
|
||||
constructor(
|
||||
private route: ActivatedRoute, private childContexts: ChildrenOutletContexts,
|
||||
private parent: Injector) {}
|
||||
|
||||
get(token: any, notFoundValue?: any): any {
|
||||
if (token === ActivatedRoute) {
|
||||
return this.route;
|
||||
}
|
||||
|
||||
if (token === ChildrenOutletContexts) {
|
||||
return this.childContexts;
|
||||
}
|
||||
|
||||
return this.parent.get(token, notFoundValue);
|
||||
}
|
||||
}
|
||||
|
||||
function isComponentFactoryResolver(item: any): item is ComponentFactoryResolver {
|
||||
return !!item.resolveComponentFactory;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue