1

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?

2
  • Can you please paste your code so that we can look into it. Jan 21, 2018 at 17:16
  • Yes you can have multiple lookup components on the same page. As Aprit asked, can you post the relevant code so we can review? Jan 21, 2018 at 21:37

1 Answer 1

2

{#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.

1
  • Thanks @sfdcfox, i understood the concept and updated my code accordingly. It resolves my issue in different way. I cannot post my code in here. Thanks for ur post. Even though it is not a direct answer to my question, i am marking ur answer as to close the question.
    – Subhash
    Jan 23, 2018 at 17:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .