I'm playing with dynamic components and i'm not able to use components from material modules, inside the dynamic component template.
It seems that imports ,of the standalone dynamic component, like MatIconModule aren't imported and the error is: mat-icon 'is not a known element'
Can material modules be used inside dynamically created standalone components?
Thank you in advance for any help!
A basic example of what i'm doing is the following:
let tpl = '<mat-icon aria-hidden="false" aria-label="This mat icon will throw error: mat-icon is not a known element" fontIcon="home"></mat-icon><testcomponent>this works ok</testcomponent>'
let component = Component({
standalone: true,
selector: 'cp1',
template: tpl,
imports: [
CommonModule, RouterModule, NgIf, NgFor, MatIconModule, MyTestComponent
]
})
(class DynamicComponentImpl extends DynamicComponent {
constructor() {
super();
}
})
container.createComponent(component, {injector: container.injector})
The component is created and added to the view, everything shows ok but components imported from material modules. In the example the mat-icon 'is not a known element'. This goes the same with other material components.