Professional Documents
Culture Documents
SF LightningComponents Cheatsheet Web
SF LightningComponents Cheatsheet Web
Cheatsheet
Overview
The Lightning Component framework helps you build responsive UIs for Force.com apps. It uses JavaScript on the client side and Apex on the server
side. This framework is based on the Aura open-source framework.
In the handling component, add this handler: Get event parameter myEvt.getParam("myAttr");
<aura:handler event="namespace:theEvent" myEvt.setParams({ "myAttr" :
Set event parameters
action="{!c.updateEvent}"/> myVal}) .fire();
Handle the event in a client-side controller.
updateEvent : function(cmp, event, helper) {
helper.updateObj(cmp,event.getParam("myObj"));
}
Core Form
Alternatively, use a component event to communicate These components are used in forms:
data to a parent component. Retrieve the event using cmp. An HTML button element used to
getEvent("cmpEvent") and fire it. <ui:button> submit a form or
execute an action.
An HTML input element of type
<ui:inputCheckbox>
checkbox.
Expressions
An HTML input element for entering
<ui:inputDate>
Use the {!...} syntax to evaluate an expression. For example, a date.
{!c.change} calls a client-side controller and {!v.myText} An HTML input element for entering
<ui:inputDateTime>
refers to a component attribute value. {!v.body} outputs the a date and time.
body of the component, which is an array
<ui:inputEmail> An HTML input element of type email.
of components.
An HTML input element for entering
<ui:inputNumber>
a number.
An HTML input element for a phone
CSS <ui:inputPhone>
number.
Use the .THIS selector with your CSS declarations to prevent styling <ui:menu> An HTML select element.
conflicts. .THIS is replaced by your component name at runtime.
A drop-down list with a trigger that
.THIS h1 { <ui:inputSelect>
padding-left: 40px; controls its visibility.
}
Core Output
Static Resources These components are used for outputting values:
Place resources in a .zip file and upload to Static Resources. <ui:outputCheckbox> Displays a read-only checkbox in
Then, use the <link> tag within the <aura:application> tag. a checked or unchecked state.
<link href="/resource/path/to/myCSS" <ui:outputDate> Displays a date based on locale.
rel="stylesheet"/>
<ui:outputDateTime> Displays a date and time based
Reference a JS or CSS resource using:
on locale.
<ltng:require scripts="/resource/JSname" styles="/
resource/CSSname" <ui:outputEmail> Displays an email address in an
afterScriptsLoaded="{!c.afterScriptsLoaded}" /> HTML anchor element.
Use yourNamespace__resourceName if you have a registered <ui:outputNumber> Displays a number based on locale.
namespace. <ui:outputPhone> Displays a phone number in an
The afterScriptsLoaded event calls a controller action after the HTML anchor element.
scripts are loaded. <ui:outputText> Displays a string of text.
Lightning Components Cheatsheet
Wiring a Component to a Controller To make a component available for Lightning Experience, create
a custom Lightning Component tab for the component, and
Add a controller system attribute to the <aura:component> assign it to an app via Create > Apps. The component will be
tag to wire a component to an Apex controller. For example: available in the App Launcher.
<aura:component controller="myNamespace.
MyApexController">