Newer Version Available
createComponent()
Create a component from a type and a set of attributes. This method
accepts the name of a type of component, a map of attributes, and a callback to notify the
caller.
Signature
createComponent(String type, Object attributes, function callback)
Parameters
- type
- Type: String
- The type of component to create. For example, "lightning:button".
- attributes
- Type: Object
- A map of attributes to send to the component. These attributes take the same form as in the markup, including events {"press":component.getReference("c.handlePress")}, and id {"aura:id":"myComponentId"}.
- callback(cmp, status, errorMessage)
- Type: function
- The callback to invoke after the component is created. The callback has three parameters.
- cmp—The component that was created. This parameter 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 are SUCCESS, INCOMPLETE, or ERROR. Always check that the status is SUCCESS before you try to use the component.
- errorMessage—The error message if the status is ERROR.