+ Start a Discussion
tulasiram chtulasiram ch 

Application Not displaying accountList please tell me where i did mistake.

AccountListComponent.cmp:
  1. <aura:component controller="AccountListController">
  2.     <aura:attribute name="Accounts" type="account[]"/>
  3.     <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
  4.     <aura:iteration items="{!v.Accounts}" var="acc">
  5.         <ui:outputText value="{!acc.name}"/>
  6.     </aura:iteration>
  7. </aura:component>
AccountListComponentController.js:
  1. ({
  2.     doInit : function(component, event, helper) {
  3.         var action = component.get("c.getAccounts");
  4.         
  5.         action.setCallback(this, function(response){
  6.             var state = response.getState();
  7.             $A.log(response);
  8.             if(state == "SUCCESS"){
  9.                 component.set("v.Accounts", response.getReturnValue());
  10.             }
  11.         });
  12.         $A.enqueueAction(action);
  13.     }
  14. })
AccountListController.apxc:
  1. public class AccountListController {
  2.     @AuraEnabled
  3.     public static List<account> getAccounts(){
  4.        list<account> accs =[select id,name from account];
  5.      return accs;
  6.     }
  7. }
harnessApp.app:
  1. <aura:application >
  2.     <div style="height: 400px;overflow: scroll; padding-top: 10px;">
  3.     <c:AccountListComponent />
  4.     </div>
  5. </aura:application>
Please give me a solution.
Best Answer chosen by tulasiram ch
PawanKumarPawanKumar
I was just wondering for the issue then finally i found that {!acc.name} is case sensitive expression in ligtning component. I just changed the expression to {!acc.Name} and it renders value. Please let me know if it works for you as well. 

Just use below code 
-------------------------------------------
<aura:component controller="AccountListController">
    <aura:attribute name="Accounts" type="account[]"/>
    <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
    <aura:iteration items="{!v.Accounts}" var="acc">
        <ui:outputText value="{!acc.Name}"/>
    </aura:iteration>
</aura:component>

Regards,
Pawan Kumar

All Answers

tulasiram chtulasiram ch
No its no working...pawankumar
PawanKumarPawanKumar
I was just wondering for the issue then finally i found that {!acc.name} is case sensitive expression in ligtning component. I just changed the expression to {!acc.Name} and it renders value. Please let me know if it works for you as well. 

Just use below code 
-------------------------------------------
<aura:component controller="AccountListController">
    <aura:attribute name="Accounts" type="account[]"/>
    <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
    <aura:iteration items="{!v.Accounts}" var="acc">
        <ui:outputText value="{!acc.Name}"/>
    </aura:iteration>
</aura:component>

Regards,
Pawan Kumar
This was selected as the best answer
PawanKumarPawanKumar
Hi Tulasiram,
Please confirm if this works for you.

Regards,
Pawan Kumar