
i want to display value as test1.user1. ho can i achieve this?
<th data-label="Id" scope="row">
<div class="slds-truncate" title="Cloudhub">
<a href="{!'/one/one.app?⌗/sObject/'+ singleRec.Id + '/view'}" target="_blank">{!singleRec.Email}</a> </div>
</th>
Hi Divya,Please refer belwo code, where I have queried a list of contacts and have displayed their username by splitting the Email with '@': Controller.js:
({
doInit : function(component, event, helper) {
var action = component.get("c.getContacts"); //fetching a list of Contacts
action.setCallback(this, function(response){
if(response.getState() == "SUCCESS"){
var result= response.getReturnValue();
var lst = [];
component.set("v.contcts", response.getReturnValue());
for(var i=0; i<result.length; i++){
let username = result[i].Email.split('@')[0];
lst.push({value:username, key:result[i]});
}
component.set("v.myMap", lst);
}
});
$A.enqueueAction(action);
}
})
CMP:
<aura:attribute name="myMap" type="Map"/>
<aura:handler name="init" value="{!this}" action="{!c.doInit}" />
<aura:iteration items="{!v.myMap}" var="mp" indexVar="key">
<tr>
<td title="Contact" style="width: 50%">
{!mp.key.Id}<br/><br/>
</td>
<td title="Email" style="width: 50%">
{!mp.value}
</td>
</tr>
</aura:iteration>