Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!----setCallBackCheck.cmp-->
- <aura:component controller="LtngServerSideController">
- <aura:attribute name="accountName" type="String"/>
- <ui:outputText value="{!v.accountName}"/>
- <ui:button press="{!c.getName}" label="Get A Name"/>
- </aura:component>
- /*--------setCallBackCheckController.js------*/
- ({
- getName : function(component, event, helper) {
- var action = component.get("c.getAccountName");
- $A.enqueueAction(action);
- action.setCallback(this,function(response)){
- var status = response.getStatus();
- if(status === "SUCCESS"){
- component.set("v.accountName", response.getReturnValue());
- }
- }
- })
- /*--------setCallBackCheckController.apxc------*/
- public class LtngServerSideController {
- @AuraEnabled
- public static string getAccountName(){
- List<account> accounts = [SELECT Id, Name FROM Account LIMIT 1];
- return accounts[0].Name;
- }
- }
- ({
- getName : function(component, event, helper) {
- var action = component.get("c.getAccountName");
- // your code as extra closing in the following line as well
- action.setCallback(this,function(response){
- // you should be using getState on result as getStatus doesn't exist in standard API
- var status = response.getState();
- if(status === "SUCCESS"){
- component.set("v.accountName", response.getReturnValue());
- }
- // your setCallback wasn't closed properly
- });
- // you enqueue the action even before it was setup
- $A.enqueueAction(action);
- }
- })
- getMyContacts : function(cmp) {
- var action = cmp.get("c.getContacts");
- action.setCallback(this,function(response) {
- var status = response.getStatus();
- if(status === "SUCCESS"){
- cmp.set("v.contacts", response.getReturnValue());
- }
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement