Components can be dynamically injected by using the$A.createComponent()
function. The syntax for this function is as follows:
$A.createComponent(String type, Object attributes, function callback)
The parameters used in the $A.createComponents
function are described as follows:
type
: The type of component to create; for example,ui:button
.attributes
: A map of attributes for the component, including the local ID (aura:id
).callback(cmp, status, errorMessage)
: Thecallback
to invoke after the component is created. Thecallback
has three parameters:cmp
: The component that was created. This enables you to do something with the new component, such as add it to the body of the component that creates it. If there's an error,cmp
is null.status
: The status of the call. The possible values areSUCCESS
,INCOMPLETE
, orERROR
. Always check that the status isSUCCESS
before you try to use the component.errorMessage
: The error message, if the status...