Activity › Forums › Salesforce® Discussions › What is aura:attribute in Salesforce?
Tagged: Attributes in Salesforce, Aura Attribute, Developer Console, Javascript, Lightning Components, Salesforce Apex Class, Visualforce
-
What is aura:attribute in Salesforce?
Posted by ABHISHEK SHAHI on September 24, 2018 at 3:20 AMWhat is aura:attribute in Salesforce?
Anjali replied 7 years, 7 months ago 4 Members · 3 Replies -
3 Replies
-
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 - [adinserter block='9']
-
aura:attribute describes an attribute available on an app, interface, component, or event. An attribute can have a type corresponding to a JavaScript function.
-
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.