Skip to content

Instantly share code, notes, and snippets.

@alexluecke
Created December 16, 2017 18:20
Show Gist options
  • Save alexluecke/cc5d22da04097794ab9bf49df5028fe4 to your computer and use it in GitHub Desktop.
Save alexluecke/cc5d22da04097794ab9bf49df5028fe4 to your computer and use it in GitHub Desktop.
<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