I am new to salesforce lightning and trying to learn it. I want to show an account information when the app is initialized. I have checked in the console, getting the value but its not displaying on the UI. Below is my code.
Component:-
<aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
<aura:attribute name="acc" type="Account"/>
<div class="slds-grid">
<div class="slds-col">{!v.acc.name}</div>
<div class="slds-col">{!v.acc.Id}</div>
<div class="slds-col">{!v.acc.Industry}</div>
</div>
Client Controller:-
({
doInit : function(component, event, helper) {
var action = component.get("c.retrieveAccount");
console.log('in client side controller');
action.setCallback(this,function(response){
var state = response.getState();
if(component.isValid() && state== "SUCCESS"){
console.log('got response');
component.set("v.acc",response.getReturnValue());
console.log('response is:- '+response.getReturnValue());
console.log('value of account '+JSON.stringify(component.get("v.acc")));
console.log('--------'+JSON.stringify(response.getReturnValue()));
}
});
$A.enqueueAction(action);
},
})
Apex controller:- GridAccountController
public class GridAccountController {
@AuraEnabled
public static Account retrieveAccount(){
System.debug('retrieveAccount');
return [SELECT Id,Name,Email__c,Industry,childCount__c,SLA__c FROM ACCOUNT LIMIT: 1];
}
}