В Angular 5/6, используя Renderer2 из @ angular / core, вы можете попробовать, как показано ниже,
constructor(private resolver: ComponentFactoryResolver, private renderer2: Renderer2) { }
createComponent(message, some_css_class) {
this.msg.reset();
const factory = this.resolver.resolveComponentFactory(MessageComponent);
const componentRef = this.entry.createComponent(factory);
componentRef.instance.message = message;
this.renderer2.addClass(componentRef.location.nativeElement, some_css_class);
}