[SalesForce] Custom lookup within Lightning Component

For my scenario, Within a Lightning component there needs to be two custom lookups.

For the first custom lookup, The code for Lightning Component is working perfectly. And when the same code is placed for another same kind of lookup for the same object, it is actually throwing an error as the component cannot get the value for undefined.

I thought that it is some ID mismatch within the code. But even if I changed the new custom lookup ids everywhere, It is still throwing an error.

Is there any limitation on Lightning Component that there should be only 1 type of custom lookup within the page. If not, I would like to know more about the expression {#someValue} with example and what is the use?

Best Answer

{#someValue} is a one-way binding. It's typical use case is when you need a value that should be set once, but never again. Here's a copy-paste Lightning App for you:

<aura:application extends="force:slds">
    <aura:attribute name="someValue" type="Integer" default="5" />
    <lightning:input type="number" name="someValue" label="Some Value" value="{!v.someValue}" />
    <lightning:input type="number" name="someValueRO" disabled="{!true}" label="Some Value (!)" value="{!v.someValue}" />
    <lightning:input type="number" name="someValueROUB" disabled="{!true}" label="Some Value (#)" value="{#v.someValue}" />
</aura:application>

Here, when you first load the app, all values are set to 5. If you edit the top field, the second field will change, but the third field will not.

You use the one-way binding when you need to initialize a value inside a component, but you don't want future changes to propagate. This is a performance benefit, because no change handlers are registered, and the fewer events fired means less processor time, which translates to a faster UI.

You'll almost never want to use this, but you should be aware that you can gain some performance in terms of loading and rendering by using one-way binding.

Related Topic