<aura:iteration items="{!v.contactlist}" var="con">
<div class="slds-col slds-size_1-of-3 slds-p-around_small">
<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}"></lightning:button>
</aura:set>
<p class="slds-p-horizontal_small">
{!con.FirstName} {!con.LastName}
</p>
<br/>
</lightning:card>
</div>
</aura:iteration>
As the lightning:button already has onClick to trigger the controller function, then why do we need <aura:set attribute="actions"> ?
Please help !
The "set" isn't there to modify the button. It gives you a way to inject stuff into right places on the lightning:card. That way your buttons will be shown consistent with other cards in the system. Otherwise you'd have to put the buttons somewhere in card's body? Or recreate whole styling manually (you could use LDS but what if style changes in future)?
See https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/components_facets.htm You can use same trick to build your own reusable components where you just inject little changes. LWC uses similar thing but it's called "slots" instead of "facets".