-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ng2.UIView): Use merged NgModule/ParentComp to inject routed com…
…ponent feat(ng2.NgModule): Add the root NgModule to root resolve
- Loading branch information
1 parent
c3857b5
commit 37241e7
Showing
5 changed files
with
114 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -341,3 +341,5 @@ export interface Ng2Component { | |
*/ | ||
uiCanExit(): HookResult; | ||
} | ||
|
||
export const NG2_INJECTOR_TOKEN = {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import {Injector} from "@angular/core"; | ||
|
||
export class MergeInjector implements Injector { | ||
static NOT_FOUND = {}; | ||
private injectors: Injector[]; | ||
constructor(...injectors: Injector[]) { | ||
if (injectors.length < 2) throw new Error("pass at least two injectors"); | ||
this.injectors = injectors; | ||
} | ||
|
||
get(token: any, notFoundValue?: any): any { | ||
for (let i = 0; i < this.injectors.length; i++) { | ||
let val = this.injectors[i].get(token, MergeInjector.NOT_FOUND); | ||
if (val !== MergeInjector.NOT_FOUND) return val; | ||
} | ||
|
||
if (arguments.length >= 2) return notFoundValue; | ||
|
||
// This will throw the DI Injector error | ||
this.injectors[0].get(token); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters