Skip to content

Instantly share code, notes, and snippets.

@tyoshikawa1106
Forked from tarot/myfirstltng.cmp
Last active September 22, 2015 08:11
Show Gist options
  • Save tyoshikawa1106/e0503d37509545d734b0 to your computer and use it in GitHub Desktop.
Save tyoshikawa1106/e0503d37509545d734b0 to your computer and use it in GitHub Desktop.
<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>
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;
}
}
({
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