Activity › Forums › Salesforce® Discussions › What is the difference between bound and unbound expressions in Salesforce?
-
What is the difference between bound and unbound expressions in Salesforce?
Posted by Prachi on August 6, 2018 at 9:01 AMWhat is the difference between bound and unbound expressions in Salesforce?
shariq replied 7 years, 7 months ago 5 Members · 4 Replies -
4 Replies
-
Hello Prachi,
Bound Expression: Bound Expression is represented as {!v.messageText}. Whenever the value of the string is changed, this expression will reflect the change and also affect the components where it is used, we can say the value change dynamically through this expression.
Unbound Expression: Unbound Expression is represented as {#v.messageText}. Whenever the value of the string is changed, this expression will not reflect the change, we can say the value remains static through this expression.
Example :
<aura:component implements=”force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction” access=”global” >
<aura:attribute name=”str” type=”string” default=”Hello World!”/>
<ui:outputText value=”Enter a string value : “/><ui:inputText value=”{!v.str}”/>
<br/><br/>
<ui:outputText value=”{#v.str}”/>
<br/><br/>
<ui:outputText value=”{!v.str}”/>
</aura:component>Thanks.
- [adinserter block='9']
-
Hi,
Bound expression syntax is: {!expression}. Curly braces with “!” bang operator is used for Bound expressions.
If you are making any change using Bound expression it will immediately reflected on your component. Bound expressions are used to reflect changes on your Lightning Component.
Unbound expression syntax is: {#expression}. Curly braces with “#” hash operator is used for Unbound expressions.
If you are making any change using unbound expression, it will not immediately reflect on your component. If you don’t want to reflect changes, you can use unbound expressions.
Note : Unbound expression changes are not reflected on component but they can be seen by javascript.
Thanks.
-
Hi
Unbound Expression: Unbound Expression is represented as {#v.messageText}. Whenever the value of the string is changed, this expression will not reflect the change, we can say the value remains static through this expression.
Bound Expression: Bound Expression is represented as {!v.messageText}. Whenever the value of the string is changed, this expression will reflect the change and also affect the components where it is used, we can say the value change dynamically through this expression.
Example :
<aura:component implements=”force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction” access=”global” >
<aura:attribute name=”str” type=”string” default=”Hello World!”/>
<ui:outputText value=”Enter a string value : “/><ui:inputText value=”{!v.str}”/>
<br/><br/>
<ui:outputText value=”{#v.str}”/>
<br/><br/>
<ui:outputText value=”{!v.str}”/>
</aura:component>Thanks.
-
Hi,
When we work with components, the first thing we do is declaring the attributes and initialize them. We use expressions for initializing our components. There are two types of expressions, bound and unbound that are used to perform data binding in Lightning Components. Let’s learn about the expressions in detail.
Bound and Unbound Expressions
Bound Expression: Bound Expression is represented as {!v.str}. Whenever the value of the string is changed, this expression will reflect the change and also affect the components where it is used, we can say the value change dynamically through this expression.Unbound Expression: Unbound Expression is represented as {#v.str}. Whenever the value of the string is changed, this expression will not reflect the change, we can say the value remains static through this expression.
Example
Create a lightning component and add the following code:<aura:component >
<aura:attribute name=”str” type=”string” default=”Hello World!”/>
<ui:outputText value=”Enter a string value : “/><ui:inputText value=”{!v.str}”/>
<br/><br/>
<ui:outputText value=”{#v.str}”/>
<br/><br/>
<ui:outputText value=”{!v.str}”/>
</aura:component>Hope this helps.
Log In to reply.