You need to sign in to do that
Don't have an account?
rishabh rathor 18
i want to show 5 accounts as in tabs and when i select on any account (in tab) then account's email should displayusing lightning component
====Component===========
<aura:component controller="AccountTabsCntrl" implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" >
<aura:handler name="init" value="{!this}" action="{!c.doinit}" />
<aura:attribute name="Accounts" type="List" />
<lightning:tabset>
<aura:iteration items="{!v.Accounts}" var="acc">
<lightning:tab label="{!acc.Name}">
{acc.Phone}
</lightning:tab>
</aura:iteration>
</lightning:tabset>
</aura:component>
=========js controller=========
({
doinit : function(component, event, helper) {
console.log('load');
var action = component.get('c.getAccounts');
action.setCallback(this, function(response){
var result =response.getReturnValue();
console.log(result);
component.set("v.Accounts",result);
console.log(result);
});
$A.enqueueAction(action);
},
})
===========Apex controller==============
public class AccountTabsCntrl {
@AuraEnabled
public static list<Account> getAccounts(id accountIds){
List<Account> accLIst = new List<Account>();
accLIst = [Select id, Name,Phone from account where Id=:accountIds Limit 5];
return accLIst;
}
}
<aura:component controller="AccountTabsCntrl" implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" >
<aura:handler name="init" value="{!this}" action="{!c.doinit}" />
<aura:attribute name="Accounts" type="List" />
<lightning:tabset>
<aura:iteration items="{!v.Accounts}" var="acc">
<lightning:tab label="{!acc.Name}">
{acc.Phone}
</lightning:tab>
</aura:iteration>
</lightning:tabset>
</aura:component>
=========js controller=========
({
doinit : function(component, event, helper) {
console.log('load');
var action = component.get('c.getAccounts');
action.setCallback(this, function(response){
var result =response.getReturnValue();
console.log(result);
component.set("v.Accounts",result);
console.log(result);
});
$A.enqueueAction(action);
},
})
===========Apex controller==============
public class AccountTabsCntrl {
@AuraEnabled
public static list<Account> getAccounts(id accountIds){
List<Account> accLIst = new List<Account>();
accLIst = [Select id, Name,Phone from account where Id=:accountIds Limit 5];
return accLIst;
}
}