When using *ngComponentOutlet
, the following code snippets are employed to handle the displaying:
Below is a snippet of functional code:
this.displayComponent({
'objects':[
{component: ToDisplayAComponent, expanded: false},
{component: ToDisplayBComponent, expanded: false}
]
})
The array of objects will be iterated using *ngFor
to display the components.
The desired functionality - passing different instances of the same abstract component initialized with unique properties - is not working as shown below:
let compA = new ToDisplayAComponent(aProperty);
let compB = new ToDisplayAComponent(anotherPropert);
this.displayComponent({
'objects':[
{component: compA, expanded: false},
{component: compB, expanded: false}
]
});
In addition to a solution to the issue at hand, I am curious about why the above code does not function correctly.
PS. It compiles but throws the following error message:
ERROR Error: No component factory found for [object Object]. Did you add it to @NgModule.entryComponents?