In the issue #32179 https://github.com/angular/angular/issues/32179 , there is an answer about rendering a component with styles, but I didn't get it.
与常春藤一起运行Angular 9
我的示例代码:
import {
ɵrenderComponent as renderComponent,
ɵdetectChanges as detectChanges,
ɵLifecycleHooksFeature as LifecycleHooksFeature,
Injector
} from '@angular/core';
....
async renderComponent() {
const { HelloWorldComponent } = await import('./hello-world.component');
this.component = renderComponent(HelloWorldComponent, {
host: this,
**rendererFactory: Didn't know what to do here.**
hostFeatures: [
LifecycleHooksFeature,
],
injector: this.injector
});
this.component.text = this.text;
detectChanges(this.component);
}