beforeremove
An event called only on component’s elements before they are removed from the document if live binding is performing the removal. It can be listened to within a component’s events object or on a component element with on:event bindings. This is an additional special event only on component elements. inserted and removed events are available on all elements.
"{element} beforeremove": function(element, event)
Listens to when the component element is removed.
This is commonly used for cleaning up and tearing down a component.
For example, the following might remove the component’s ViewModel from a parent component’s ViewModel:
events: {
"{element} beforeremove": function(){
canViewModel(this.element.parentNode)
.removePanel(this.viewModel);
}
}
Parameters
- element
{HTMLElement}
:The component element.
- event
{Event}
:The
beforeremove
event object.
($beforeremove)="CALL_EXRESSION"
Uses on:event bindings to listen for a component’s
beforeremove
event.
<my-panel ($beforeremove)="removePanel(%viewModel)"/>
Parameters
- CALL_EXRESSION
{Call Expression}
:A call expression that calls some method when the event happens.