Activity Forums Salesforce® Discussions What is the use of aura:id in Salesforce lightning component?

  • Piyush

    Member
    November 5, 2019 at 5:56 am

    Hi,

    aura:id is a local id. A local ID is an ID that is only scoped to the component. A local ID is often unique but it’s not required to be unique.

    Ex.-<lightning:button aura:id="button1" label="button1"/>

    • This reply was modified 5 years, 1 month ago by  Piyush.
  • Nikita

    Member
    November 5, 2019 at 6:05 am

    Hi Laveena,

    You can retrieve a component using its local ID in your JavaScript code. A local ID is an ID that is only scoped to the component. A local ID is often unique but it’s not required to be unique. Local ID is created by the aura:id attribute.

    For Example:

    <lightning:button aura:id="button1" label="button1"/>

    Find the button component by calling cmp.find("button1") in your client-side controller, where cmp is a reference to the component containing the button.

    find() returns different types depending on the result.

    • If the local ID is unique, find() returns the component.
    • If there are multiple components with the same local ID, find() returns an array of the components.
    • If there is no matching local ID, find() returns undefined.

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos