Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <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>
- ({
- doInit : function(component, event) {
- var action = component.get("c.findAll");
- action.setCallback(this, function(a) {
- component.set("v.contacts", a.getReturnValue());
- });
- $A.enqueueAction(action);
- }
- public with sharing class ContactListController {
- public static List<Contact> findAll() {
- return [SELECT id, name, phone FROM Contact LIMIT 50];
- }
- }
- public with sharing class ContactListController {
- @AuraEnabled
- public static List<Contact> findAll() {
- return [SELECT id, name, phone FROM Contact LIMIT 50];}}
- function(components, status, errorMessage){
- if (status === "SUCCESS") {
- //DO SOMETHING
- }
- else if (status === "INCOMPLETE") {
- console.log("No response from server or client is offline.")
- // Show offline error
- }
- else if (status === "ERROR") {
- console.log("Error: " + errorMessage);
- // Show error message
- }
Add Comment
Please, Sign In to add comment