Skip to content

Instantly share code, notes, and snippets.

@shinchit
Last active September 16, 2019 22:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shinchit/2dfcc65a802be11f6e89245343ab7c5a to your computer and use it in GitHub Desktop.
Save shinchit/2dfcc65a802be11f6e89245343ab7c5a to your computer and use it in GitHub Desktop.
<aura:component>
<aura:attribute name="contacts" type="Contact[]" />
<aura:handlr name="change" value="{!v.contacts} action="{!c.changeContacts}" />
<div aura:id="container">
</div>
</aura:component>
({
changeContacts : function(component, event, helper) {
helper.loadContactItems(component);
}
})
({
loadContactItems : function(component) {
let contacts = component.getReference("v.contacts") || [];
let container = component.find("container");
$A.createComponent(
"c:ContactItems",
{
"aura:id": "ContactItemsComponent",
"contacts": contacts
},
function(newContactItems, status, errorMessage) {
if (status === "SUCCESS") {
container.set("v.body", [newContactItems]);
} else if (status === "INCOMPLETE") {
console.log("No response from server or client is offline.");
} else if (status === "ERROR") {
console.log("Error: " + errorMessage);
}
}
);
}
})
<aura:component>
<aura:attribute name="contacts" type="Contact[]"/>
<aura:iteration items="{!v.contacts}" var="p">
<c:ContactItem fullName="{!p.Name}" accountName="{!p.Account.Name}" />
</aura:iteration>
</aura:component>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment