Skip to main content
({

    doInit : function(component, event, helper) {

        

         /* Step 1*/

        var action=component.get('c.getContact');

        

        

        /*Optional*/  /* Step 1*/

        action.setParams({

            accountId : componenet.get

        });

        

         /* Step 4*/

        action.setCallback(this, function(response){

            var  responseValue =  response.getReturnValue();

            console.log('responseValue', responseValue);

            component.set('v.contactList',responseValue);

        },'SUCCESS');

        

         /* Step 3*/

        $A.enqueueAction(action,false);

    },

    doRedirect: function(component, event, helper){

        var events=event.getSource();

        var id=eventSource.get('v.name');

        alert(id);

    }

})

<aura:component controller="ContactList2"     

                implements="force:hasRecordId, flexipage:availableForAllPageTypes">

    <aura:attribute name="contactList" type="Contact[]"/>

    

    <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>

     {!v.recordId}

    <div class="slds-p-around_xx-small">

    <aura:iteration items="{!v.contactList}" var="con">

        <lightning:card title="{!con.LastName}" footer="{!con.Email}" iconName="standard:contact">

            <aura:set attribute="actions">

                <lightning:button  name ="{!con.ID}" label="View Details" variant="brand" onclick="{!c.doRedirect}"/>

            </aura:set>

            <div class="slds-p-horizontal_xxx-small">

        {!con.FirstName} &nbsp;{!con.LastName} <br/>

        {!con.Email}  {!con.Phone}

                </div>

            </lightning:card>

    </aura:iteration>

    </div>

</aura:component>
4 respuestas
  1. 19 jul 2021, 4:25
    Hi Hemant,

    Please compare your code with 

    /*Optional*/ /* Step 1*/

    action.setParams({

    accountId : component.get('v.recordId')

    });

    if you need any assistanse, Please let me know!!

    Kindly mark my solution as the best answer if it helps you.

    Thanks

    Mukesh 
0/9000