Activity Forums Salesforce® Discussions What is aura:attribute in Salesforce?

  • shariq

    Member
    September 24, 2018 at 3:21 am

    They are same as member variable in apex classes, they are typed fields and are instance of a component. Attribute helps in making component more dynamic.

    All attributes have a name and a type can be marked required by specifying ‘required=true’and can also have a default value. It has a naming rule as well:

    1. Must begin with a letter or an underscore
    2. Must contain only alphanumeric or underscore characters

  • Avnish Yadav

    Member
    September 28, 2018 at 7:23 am

    aura:attribute describes an attribute available on an app, interface, component, or event. An attribute can have a type corresponding to a JavaScript function.

  • Anjali

    Member
    September 28, 2018 at 1:13 pm

    Hi,

    Attributes are named parameters in your component that you can display, manipulate and otherwise interact with throughout the component.

    In your Developer Console, navigate to New > Lightning Component, and create a new bundle named abcComponent2. Add the following code and save.

    <aura:component >
    <aura:attribute name="greeting" type="String" default="Hello!" />
    <h1>Component 2 - Attributes</h1>
    <p>{!v.greeting} from Aura.</p>
    </aura:component>

    You’ll notice that the attribute is called “greeting” and that the expression {!v.greeting} also refers to “greeting”. The {!something} syntax is likely familiar to anyone who’s worked in Visualforce. The v in {!v.something} represents the “view”. So one way to think of how this component works is that the <aura:attribute /> tag puts a field on the view with a default value, and the {!v.something} pulls the value of the field out of the view and does something with it.

     

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos