I have a variable containing the name of a component as a string. I'm looking for a way to pass this variable to another object property as the actual component object rather than just a string.
Is there a global array that holds all the components for the entire application that I can reference? Perhaps something like this:
let componentName = 'myComponentName';
componentsArray[componentName];
Alternatively, is there a way to convert or cast the variable to type :Component?
Update...
I am currently setting up a routing configuration;
const routes: Routes = [
{
path: 'home',
component: componentName
},
{
path: 'services',
component: componentName
},
{
path: '',
component: componentName
},
{
path: '**',
component: componentName
}
];