cf-dynamic-component-loader
Loader of existing components.
Copy ... ,
entryComponents : [
CfDemoDynamicComponentLoaderExampleOne ,
CfDemoDynamicComponentLoaderExampleTwo ,
CfButtonComponent ,
CfWeatherComponent
]
...
selectedComponent : any;
button = new ButtonModel ({
label : "My CfButtonComponent" ,
color : {
foreground : "black" ,
background : "primary"
} ,
iconProperty : null ,
iconPosition : "right"
});
weather = new WeatherComponentModel ({
defaultCity : "Paris"
});
selectComponent (componentName) {
switch (componentName) {
case 1 :
this .selectedComponent = {
component : CfDemoDynamicComponentLoaderExampleOne ,
inputs : {
inputText : 'This is example one.'
}
};
break ;
case 2 :
this .selectedComponent = {
component : CfDemoDynamicComponentLoaderExampleTwo ,
inputs : {
onClick : () => {
alert ( 'This is example two.' );
}
}
};
break ;
case 3 :
this .selectedComponent = {
component : CfButtonComponent ,
inputs : {
settings : this .button
}
};
break ;
case 4 :
this .selectedComponent = {
component : CfWeatherComponent ,
inputs : {
settings : this .weather
}
};
break ;
}
}
Copy <button md-button="" (click)="selectComponent(1)">Select Component One</button>
<button md-button="" (click)="selectComponent(2)">Select Component Two</button>
<button md-button="" (click)="selectComponent(3)">Select CfButtonComponent</button>
<button md-button="" (click)="selectComponent(4)">Select CfWeatherComponent</button>
<div id="cf-dynamic-component-loader-container">
<cf-dynamic-component-loader [componentData]="selectedComponent"></cf-dynamic-component-loader>
</div>
Copy #cf-dynamic-component-loader-container {
margin-top : 15 px ;
}
Component loader componentData properties