function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
RishavRishav 

aura:iteration not showing records from sObject

Hii, 
I was just trying to learn some aura comonent, while trying with aura:iteration to take dynamic value it's not working
<aura:component>
  <aura:attribute name="expenses" type="rishav.Expense__c[]"/> 
   <div class="row">
       <aura:iteration items="{!v.expenses}" var="expense"> 
           <p>{!expense.Name}, {!expense.rishav__Client__c}, {!expense.rishav__Amount__c},
               {!expense.rishav__Date__c}, {!expense.rishav__Reimbursed__c}
           </p> 
       </aura:iteration>
    </div>
</aura:component>
I am not getting where i am doing mistake , but it is not showing any record even after some records are there in my database.
Can anyone tell me where i am doing mistake.
 
Thanks
Rishav
Best Answer chosen by Rishav
RishavRishav
Hii All,
After lots of mugging up i solved my problem,
Finally i found the answer of this question :
The solution is this line that i found in TrailHead " To use your record data in a Lightning component, you must wire up an Apex controller to the component.
It means that <aura:iteration> won't work with your database object untill u wire up a controller class in your component. and write the method inside the controller to fetch the data . 

You can follow this link
https://developer.salesforce.com/trailhead/lightning_components/lightning_components_apex

Thanks
Rishav

All Answers

RishavRishav
Hii All,
After lots of mugging up i solved my problem,
Finally i found the answer of this question :
The solution is this line that i found in TrailHead " To use your record data in a Lightning component, you must wire up an Apex controller to the component.
It means that <aura:iteration> won't work with your database object untill u wire up a controller class in your component. and write the method inside the controller to fetch the data . 

You can follow this link
https://developer.salesforce.com/trailhead/lightning_components/lightning_components_apex

Thanks
Rishav
This was selected as the best answer
Amit Tamse 88Amit Tamse 88
The link is broken.