Angular 2: Remove CSS from a dynamically created component when destroyed

Viewed 538

How do I remove all CSS classes that were added to the DOM when I destroy a dynamically created component.

Create Component (which add the component's CSS classes to the DOM):

const componentFactory = this.componentFactoryResolver.resolveComponentFactory(component)
const componentRef = componentFactory.create(this.injector)

Destroy component

componentRef.destory()
// I need the CSS Classes which were added to the DOM to be destroyed as well

I cannot manually remove them because I will have no Idea what the CSS classes are; therefore, I need to remove all CSS classes tied the creation of that component.

0 Answers
Related