Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<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
You can’t perform that action at this time.