Activity Forums Salesforce® Discussions What is the difference between bound and unbound expressions in Salesforce?

  • shradha jain

    Member
    August 7, 2018 at 5:30 am

    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.

  • madhulika shah

    Member
    September 17, 2018 at 10:30 am

    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.

  • Parul

    Member
    September 21, 2018 at 10:21 am

    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.

  • shariq

    Member
    September 22, 2018 at 3:45 am

    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.

Popular Salesforce Blogs

AI in Salesforce

Transform businesses with the power of Artificial Intelligence leveraged through Salesforce Einstein

Blog in

Artificial Intelligence is powering next-generation customer experiences with smart predictions, intelligent recommendations, timely automation and much more. Gartner predicts that by 2020, a staggering 85% of…