#dynamic components and material module import

2 messages · Page 1 of 1 (latest)

feral trench
#

Hello,
I'm playing with dynamic components and i'm not able to use components from material modules.
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.

Can material modules be used inside dynamically created standalone components?

Thank you in advance for any help!

#

dynamic components and material module import