Skip to content

Instantly share code, notes, and snippets.

@msrivastav13
Last active August 14, 2016 05:07
Show Gist options
  • Save msrivastav13/b48f3cdf22040a018628b683b8fb9a61 to your computer and use it in GitHub Desktop.
Save msrivastav13/b48f3cdf22040a018628b683b8fb9a61 to your computer and use it in GitHub Desktop.
Simple class to fetch data from SFDC Account Table
public with sharing class AccountTest{
@AuraEnabled
public static list<Account> getlstacc(){
return [Select Id , Name , NumberofLocations__c from Account order by NumberofLocations__c limit 10];
}
}
<aura:component controller="AccountTest" access="global">
<aura:handler name="init" action="{!c.fetchAccounts}" value="{!this}" />
<aura:attribute name="accounts" type="Account[]" />
<ul>
<aura:iteration items="{!v.accounts}" var="account">
<li > <h3>{!account.name}</h3> </li>
<li > <h3>{!account.NumberofLocations__c}</h3> </li>
</aura:iteration>
</ul>
</aura:component>
({
fetchAccounts : function(component, event, helper) {
var action = component.get("c.getlstacc ");
action.setCallback(this, function(data) {
component.set("v.accounts", data.getReturnValue());
});
$A.enqueueAction(action);
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment