0

When creating a dynamic standalone component at runtime the HTML renders in the ViewContainerRef but angular materials does not work with the exception of MatIcon. Please see the example of code

    const compMetadata = new Component({
      standalone: true,
      selector: selector,
      imports:[NgIf,NgForOf, NgSwitch,AsyncPipe ,MatIconModule,MatButtonModule,DynamicComponentLoader],
      schemas: [ CUSTOM_ELEMENTS_SCHEMA ],
      template: component.rawHTML,
      styles: component.rawCss,
    });
    const dynamicComponent = await Component(compMetadata)(class DynamoComponentBuild {
      showme = true
    });
   
    // console.log('ClassName',className,selector,compMetadata);
     const ref = this.dcc.createComponent(dynamicComponent as Type<unknown>);

I have attempted to add the 'CommonModule' in the imports with no avail. Any suggestions or help would be greatly appreciated.

1 Answers1

0

temporary solution was to downgrade the angular materials library to version @angular/material@12.0.2. It seems version 13 has a bug that does not render correctly in standalone components.