0

I know I can add an element to an Angular 2 directive like this:

this._renderer.createElement(this._el.nativeElement.parentNode, 'div');

How do I set the class of that added element and get a reference to it to remove at a later date?

1 Answer 1

1

I just did that through.

let ele = this.renderer.createElement(this.el.nativeElement.parentNode, "div");
this.renderer.setElementClass(ele, "my-class", true);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.