Dynamically creating components using $A.createComponent()
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): Thecallbackto invoke after the component is created. Thecallbackhas 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,cmpis null.status: The status of the call. The possible values areSUCCESS,INCOMPLETE, orERROR. Always check that the status isSUCCESSbefore you try to use the component.errorMessage: The error message, if the status...