Guest User

Untitled

a guest
Dec 15th, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. <aura:component controller="ContactListController">
  2.  
  3. <aura:attribute name="contacts" type="Contact[]"/>
  4. <aura:handler name="init" value="{!this}" action="{!c.doInit}" />
  5. <aura:iteration items="{!v.contacts}" var="contact">
  6. <p>{!contact.Name}</p>
  7. <p>{!contact.Phone}</p>
  8. </aura:iteration>
  9. </aura:component>
  10.  
  11. ({
  12. doInit : function(component, event) {
  13. var action = component.get("c.findAll");
  14. action.setCallback(this, function(a) {
  15. component.set("v.contacts", a.getReturnValue());
  16. });
  17. $A.enqueueAction(action);
  18. }
  19.  
  20. public with sharing class ContactListController {
  21. public static List<Contact> findAll() {
  22. return [SELECT id, name, phone FROM Contact LIMIT 50];
  23. }
  24. }
  25.  
  26. public with sharing class ContactListController {
  27. @AuraEnabled
  28. public static List<Contact> findAll() {
  29. return [SELECT id, name, phone FROM Contact LIMIT 50];}}
  30.  
  31. function(components, status, errorMessage){
  32. if (status === "SUCCESS") {
  33.  
  34. //DO SOMETHING
  35. }
  36. else if (status === "INCOMPLETE") {
  37. console.log("No response from server or client is offline.")
  38. // Show offline error
  39. }
  40. else if (status === "ERROR") {
  41. console.log("Error: " + errorMessage);
  42. // Show error message
  43. }
Add Comment
Please, Sign In to add comment