Using Expression syntax

The syntax for the Expression is {!expression}. The Expression syntax can be used inside the Component Markup. Let's take a look at the following table to see the syntax for Expressions in different scenarios:

Expression Example Syntax Example Code
Expression to reference a value from an attribute {!v.attributeName}
<aura:component>
<aura:attribute name="searchString" type="String" default="lighnting components"/>

<p>{!v.searchString}</p>
</aura:component>
Expression for calling client-side controller actions {!c.handleClick}
<Lightning:button label="Framework Button" onclick="{!c.handleClick}"/>

The client-side JavaScript controller will be as following


({
handleClick : function(component, event) {

}
})
Expression operator The operators supported are listed in the standard docs. Please refer to: https://developer.Salesforce.com/docs/atlas.en-us.Lightning.meta/Lightning/expr_operators.htm
<aura:component>
<aura:attribute name="searchString" type="String" default="lighnting components"/>

<p>{!'Hello' + v.searchString}</p>
</aura:component>
Expression function The supported functions are listed here: https://developer.Salesforce.com/docs/atlas.en-us.Lightning.meta/Lightning/expr_functions.htm
<aura:component>
<aura:attribute name="searchString" type="String" default="lighnting components"/>

<p>
{!concat('Hello',v.searchString)}
</p>
</aura:component>
To become familiar with all the operators and functions, refer to the Lightning Component Developer guide documentation at: https://developer.Salesforce.com/docs/atlas.en-us.Lightning.meta/Lightning/expr_overview.htm
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.16.139.8