Created
December 16, 2017 18:20
-
-
Save alexluecke/cc5d22da04097794ab9bf49df5028fe4 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
<ng-container [ngSwitch]="condition"> | |
<component-A *ngSwitch="condition"></component-A> | |
<component-B *ngSwitch="condition"></component-B> | |
</ng-container> | |
@Component( | |
providers: [ | |
{ provide: ABC, useClass: ConcreteAClass } | |
] | |
) | |
class ComponentA extends GenericBase { | |
constructor() {} | |
} | |
@Component( | |
providers: [ | |
{ provide: ABC, useClass: ConcreteBClass } | |
] | |
) | |
class ComponentB extends GenericBase { | |
constructor() {} | |
} | |
// Then in component A and B you can render the same component that gets different injections based on the parent component | |
@Component() | |
class SubComponent { | |
constructor( | |
abc: ABC | |
) { } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment