Skip to content

Instantly share code, notes, and snippets.

@filipbech
Created October 25, 2017 17:33
Show Gist options
  • Save filipbech/2e216f644f0404f4063ed450524b633e to your computer and use it in GitHub Desktop.
Save filipbech/2e216f644f0404f4063ed450524b633e to your computer and use it in GitHub Desktop.
More dynamic example
@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