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>
Simple but perfect for what I needed. Thanks!
ReplyDeleteGreat for the template way, but how can i do that in the component ts?.
ReplyDeleteThanks
@elpana :
ReplyDelete@ViewChild('myElement') private myElementContainer:ElementRef;
this.myElementContainer.nativeElement.innerHTML = '';
add this to your code.
Nice!
ReplyDeleteAnother disadvantage that some people feel is part https://baccarat.team/ of online casinos also has to do with the lack of physical contact and that disadvantage is the one about money. Some people do not like seeing their money as electronic and not real bills in their hand.
ReplyDeleteWith us, you will no longer have to worry about having neither time to complete the assignment ( https://beekeepclub.com/causes-of-environmental-and-climate-change/ ) nor ideas on how to start writing an essay. We’ve got you covered.
ReplyDelete