Renderer2
Extend this base class to implement custom rendering. By default, Angular renders a template into DOM. You can use custom rendering to intercept rendering calls, or to render to something other than DOM.
abstract class Renderer2 {}
data
{ [key: string]: any; }
Use to store arbitrary developer-defined data on a renderer instance, as an object containing key-value pairs. This is useful for renderers that delegate to other renderers.
destroy
void
Implement this callback to destroy the renderer or the host element.
void
createElement
any
Implement this callback to create an instance of the host element.
string
An identifying name for the new element, unique within the namespace.
string | null | undefined
The namespace for the new element.
any
createComment
any
Implement this callback to add a comment to the DOM of the host element.
string
The comment text.
any
createText
any
Implement this callback to add text to the DOM of the host element.
string
The text string.
any
destroyNode
((node: any) => void) | null
If null or undefined, the view engine won't call it. This is used as a performance optimization for production mode.
appendChild
void
Appends a child to a given parent node in the host element DOM.
any
The parent node.
any
The new child node.
void
insertBefore
void
Implement this callback to insert a child node at a given position in a parent node in the host element DOM.
any
The parent node.
any
The new child nodes.
any
The existing child node before which newChild
is inserted.
boolean | undefined
Optional argument which signifies if the current insertBefore
is a result of a
move. Animation uses this information to trigger move animations. In the past the Animation
would always assume that any insertBefore
is a move. This is not strictly true because
with runtime i18n it is possible to invoke insertBefore
as a result of i18n and it should
not trigger an animation move.
void
removeChild
void
Implement this callback to remove a child node from the host element's DOM.
any
The parent node.
any
The child node to remove.
boolean | undefined
Optionally signal to the renderer whether this element is a host element or not
void
selectRootElement
any
Implement this callback to prepare an element to be bootstrapped as a root element, and return the element instance.
any
The DOM element.
boolean | undefined
Whether the contents of the root element
should be preserved, or cleared upon bootstrap (default behavior).
Use with ViewEncapsulation.ShadowDom
to allow simple native
content projection via <slot>
elements.
any
parentNode
any
Implement this callback to get the parent of a given node in the host element's DOM.
any
The child node to query.
any
nextSibling
any
Implement this callback to get the next sibling node of a given node in the host element's DOM.
any
any
setAttribute
void
Implement this callback to set an attribute value for an element in the DOM.
any
The element.
string
The attribute name.
string
The new value.
string | null | undefined
The namespace.
void
removeAttribute
void
Implement this callback to remove an attribute from an element in the DOM.
any
The element.
string
The attribute name.
string | null | undefined
The namespace.
void
addClass
void
Implement this callback to add a class to an element in the DOM.
any
The element.
string
The class name.
void
removeClass
void
Implement this callback to remove a class from an element in the DOM.
any
The element.
string
The class name.
void
setStyle
void
Implement this callback to set a CSS style for an element in the DOM.
any
The element.
string
The name of the style.
any
The new value.
void
removeStyle
void
Implement this callback to remove the value from a CSS style for an element in the DOM.
any
The element.
string
The name of the style.
void
setProperty
void
Implement this callback to set the value of a property of an element in the DOM.
any
The element.
string
The property name.
any
The new value.
void
setValue
void
Implement this callback to set the value of a node in the host element.
any
The node.
string
The new value.
void
listen
() => void
Implement this callback to start an event listener.
any
The context in which to listen for events. Can be the entire window or document, the body of the document, or a specific DOM element.
string
The event to listen for.
(event: any) => boolean | void
A handler function to invoke when the event occurs.
() => void