Angular1 provides angular.element by to create JavaScript element. In Angular2, It is much easy, you can define element by using #<element name> as attribute

Markup to define element

<div #myElement>
  sample text in div
</div>

Emptying Element

You can empty element by using making whole inner HTML as null. Find below markup
<button (click)="myElement.innerHTML = ''">Empty div</button>

Remove Element

You can remove element by using .remove()
<button (click)="myElement.remove()">Empty div</button>
View DEMO

1 comment:

Blogroll

Follow this blog by Email

Popular Posts