Activity Forums Salesforce® Discussions What is attribute in Salesforce Lightning?

  • Ratnesh

    Member
    January 30, 2020 at 1:05 pm

    It is like a member variable in our regular coding. In others words, attributes are used to store information to be referenced and used in our lightning component code.

    It will make your lightning component more dynamic.

  • Anjali

    Member
    January 30, 2020 at 1:15 pm

    Component attributes are like member variables on a class in Apex. They are typed fields that are set on a specific instance of a component, and can be referenced from within the component's markup using an expression syntax. Attributes enable you to make components more dynamic.

  • Aditya

    Member
    January 30, 2020 at 1:16 pm

    Hi Ayush,

    Attribute is generally used as a variable in Salesforce Lightning Component to hold value/information

  • Shweta

    Member
    January 30, 2020 at 1:18 pm

    Attribute : It is used to store information to be referenced  in our lightning component code. Attributes on components are like instance variables in objects. It have a name and a type.

    <aura:attribute> tag is used  to add an attribute to the component.

    Example :

    <aura:component>
        <aura:attribute name="message" type="String"/>
        <p>{!'Hello! ' + v.message}</p>
    </aura:component>

     

  • Manish

    Member
    January 30, 2020 at 1:29 pm

    Hi Ayush

    Attribute is an lightning component, and used to declare variables in same way as we declare in apex:

    Example: <aura:attribute name="accObj" type="String" description="account Object" access="public" default="{'sobjectType': 'Account', 'Name': '', 'Website': '', 'Phone': '', 'Description': '', 'Industry': ''}" />

    public static Account accObj;

Log In to reply.

Popular Salesforce Blogs