Last active
September 22, 2015 08:11
-
-
Save tarot/2ab5aea54969bde49d83 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<aura:component implements="force:appHostable" controller="myfirstltngController"> | |
<aura:attribute name="account" type="Account"/> | |
<aura:handler name="init" action="{!c.init}" value="{!this}"/> | |
{!v.account.Name} | |
<button onclick="{!c.save}">click</button> | |
</aura:component> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public with sharing class myfirstltngController { | |
@AuraEnabled | |
public static Account retrieveAccount() { | |
return [select Id, Name from Account limit 1]; | |
} | |
@AuraEnabled | |
public static void saveAccount(Account account) { | |
system.debug(account); | |
upsert account; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
({ | |
init : function(component, event, helper) { | |
var action = component.get('c.retrieveAccount'); | |
action.setCallback(this, function(data) { | |
component.set('v.account', data.getReturnValue()); | |
}); | |
$A.enqueueAction(action); | |
}, | |
save: function(component, event, helper) { | |
component.set('v.account.Name', component.get('v.account.Name') + 'x') | |
var action = component.get('c.saveAccount'); | |
action.setParams({account: component.get('v.account')}); | |
$A.enqueueAction(action); | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment