I am not getting server side values in my javascript.
Markup
<aura:component controller="ContactListController">
<aura:attribute name="contacts" type="Contact[]"/>
<aura:handler name="init" value="{!this}" action="{!c.doInit}" />
<aura:iteration items="{!v.contacts}" var="contact">
<p>{!contact.Name}</p>
<p>{!contact.Phone}</p>
</aura:iteration>
</aura:component>
Script
({
doInit : function(component, event) {
var action = component.get("c.findAll");
action.setCallback(this, function(a) {
component.set("v.contacts", a.getReturnValue());
});
$A.enqueueAction(action);
}
Apex
public with sharing class ContactListController {
public static List<Contact> findAll() {
return [SELECT id, name, phone FROM Contact LIMIT 50];
}
}