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
supriya Goresupriya Gore 

Trying to display list of records for custom object using lightning component but my code is not working properly

component:
<aura:component implements="force:appHostable" controller="FetchRegistrations" >
    <aura:attribute name="reg" type="Registration__c[]"/>
    <ui:button label="Get Registrations" press="{!c.myAction}"/>
    <aura:iteration var="r" items="{!v.reg}" >
    <p>{!r.name}</p>
    </aura:iteration>
</aura:component>


Controller:
({
   myAction : function(component, event, helper) {
        var action = component.get("c.getAllregistrations");
        action.setCallback(this, function(response){
            var name = response.getState();
            if (name === "SUCCESS") {
                component.set("v.reg", response.getReturnValue());
            }
        });
     $A.enqueueAction(action);
    }
})

Apex:
global with sharing class FetchRegistrations {
@auraEnabled
    public static List<Registration__c> getAllregistrations()
    {
     List<Registration__c> reg=new LIST<Registration__c>();  
        reg=[select id,name,Email__c from Registration__c];
        return reg;
    } 
    public Registration__c getSelectedregistrations(Id id)
    {    
      Registration__c  reg=[select id,name,Email__c from Registration__c where id=:id];
        return reg;
    } 
   
}
Best Answer chosen by supriya Gore
Prajyot KerkarPrajyot Kerkar
Change {!r.name} to {!r.Name} as javascript is case-sensitive name & Name are different

All Answers

Florian HansenFlorian Hansen
What exactly is not working?
supriya Goresupriya Gore
Hi Florian,
After clicking button,i am getting blank page.
Prajyot KerkarPrajyot Kerkar
Change {!r.name} to {!r.Name} as javascript is case-sensitive name & Name are different
This was selected as the best answer
supriya Goresupriya Gore
Hi Prajyot,
Yeeeeh its working...!Thanks
 
peter paul 1peter paul 1
I understand your problem, you can take help from Hotmail customer service (https://emailsupports.net/hotmail-support/) to solve it, I took help from then of my java and PHP projects.
Vireak RenVireak Ren
2020 *
I want to show more fields ex: {!r.name....Id....billingcity}
How to do?