Created
October 25, 2017 17:33
-
-
Save filipbech/2e216f644f0404f4063ed450524b633e to your computer and use it in GitHub Desktop.
More dynamic example
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
@Component({ ... }) | |
class ExampleComponent { | |
static name = 'Some arbitrary name'; | |
} | |
/*list of componentClasses that should be available this way*/ | |
const allComponents = [ ExampleComponent, /*more...*/ ]; | |
@Component({ | |
template:` | |
<component [component]="cmp" ></component> | |
` | |
}) | |
class UsesComponent { | |
useComponent(name) { | |
this.cmp = allComponents.find(cmp=>cmp.name === name); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment