Working with a Component Body in JavaScript
These are useful and common patterns for working with a component’s body in JavaScript.
In these examples, cmp is a reference to a component in your JavaScript code. It’s usually easy to get a reference to a component in JavaScript code. Remember that the body attribute is an array of components, so you can use the JavaScript Array methods on it.
When you use cmp.set("v.body", ...) to set the component body, you must explicitly include {!v.body} in your component markup.
To replace the current value of a component’s body with another component:
To clear or empty the current value of a component’s body:
To append a newCmp component to a component’s body:
To prepend a newCmp component to a component’s body:
To remove an indexed entry from a component’s body:
See Also