Reputation: 7392
I am creating a salesforce lightning component to list the leads of the current logged in user.
I have managed to write the following code, but when i add the component to the page, and preview it, I dont see any leads.
<aura:component implements="forceCommunity:availableForAllPageTypes" access="global" >
<div class="slds">
<table class="slds-table slds-table--bordered slds-table--striped">
<thead>
<tr>
<th scope="col"><span class="slds-truncate">Company</span></th>
<th scope="col"><span class="slds-truncate">Annual Revenue</span></th>
</tr>
</thead>
<tbody>
<aura:iteration items="{!v.leads}" var="lead">
<tr>
<td>{!lead.Company}</td>
<td>{!lead.AnnualRevenue}</td>
</tr>
</aura:iteration>
</tbody>
</table>
</div>
It will be great, if someone could tell me what is that I am doing wrong. Thank you
Upvotes: 0
Views: 1416
Reputation: 51
This might be because
You have not added a controller on your lightning component.
<aura:component implements="forceCommunity:availableForAllPageTypes" controller="ContactController" access="global" >
You have not declared the attribute "leads" which you have used in the iteration.
<aura:attribute name="leads" type="Lead[]"/>
You have not set the "leads" attribute which you fetched from the Apex controller.
controller.set("v.leads", variableWithLeadsList);
You have not fetched data from the Apex controller. In this case, as mentioned by Rajdeep Dua, https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/events_one_demo_load.htm link explains the whole process and will help you if you replace Contact with Lead.
Upvotes: 0
Reputation: 11230
You can follow the tutorial for Displaying a Contact List and replace the Logic with that for Leads
https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/events_one_demo_load.htm
Upvotes: 1