I\'ve based some of my work on the same problem described in here:
dynamic template to compile dynamic Component with Angular 2.0
How can I use/create dynami
If your change "text-editor"
to "dynamic-detail"
then your template will look like:
<form>
<dynamic-detail
[propertyName]="'code'"
[entity]="entity"
></dynamic-detail>
<dynamic-detail
[propertyName]="'description'"
[entity]="entity"
></dynamic-detail>
</form>
DynamicDetail
component doesn't have propertyName
and entity
properties.
So you can add their.
detail.view.ts
export class DynamicDetail implements AfterViewInit, OnChanges, OnDestroy, OnInit
{
@Input() public propertyName: string;
@Input() public entity: any;
Second part of solution is add this component to RuntimeComponentModule
:
type.builder.ts
protected createComponentModule (componentType: any) {
@NgModule({
imports: [
PartsModule,
DynamicModule.forRoot() // this line
],
declarations: [
componentType
],
})
class RuntimeComponentModule {}
return RuntimeComponentModule;
}
After that it should work Plunker Example