Attribute act as a variable to store different types of values.
Example:
<aura:attribute name="Anyname" type ="string" description="some description" default="some default string" />
Name and type are a parameter of an attribute that is always required in attributes, the description is another parameter where we can mention about description of attribute. Description is not a required parameter. Similarly, we have a default parameter to give some default value to attribute. To set the access for an attribute we have access parameter where we can specify public, private, global access for an attribute. By default, the attribute have public access.
To make the attribute required we have required parameter where we can set true or false.
Let start with the basic attributes,
1) Boolean
Syntax:
<aura:attribute name="Anyname" type="Boolean" />
We can use the boolean attribute when we want to store boolean results.
2) Integer
Syntax:
<aura:attribute name="Anyname" type="Integer" />
We can use the integer type attribute for storing integer type values.
for ex: 1,2,3 etc.
3) String
Syntax:
<aura:attribute name="Anyname" type="String" />
We can store some text value inside the string type attribute.
ex: some text 1,some text2 etc.
4) Date
Syntax:
<aura:attribute name="Anyname" type="Date" />
5) DateTime
Syntax:
<aura:attribute name="Anyname" type="DateTime" />
6) Double
Syntax:
<aura:attribute name="Anyname" type="Double" />
To store fractional values.
7) Decimal
Syntax:
<aura:attribute name="AnyName" type="Decimal" />
Decimal is better than Double for maintaining precision for floating-point calculations. It’s preferable for currency fields.
8) Long
Syntax:
<aura:attribute name="AnyName" type="Long" />
Long values can contain numbers with no fractional portion. Use this data type when you need a range of values wider than those provided by Integer.
We can use arrays for each of these basic types.
As an example,
<aura:attribute name="fruitsList" type="String[]" default="['apple','mango','orange']" />
Example:
<aura:attribute name="Anyname" type ="string" description="some description" default="some default string" />
Name and type are a parameter of an attribute that is always required in attributes, the description is another parameter where we can mention about description of attribute. Description is not a required parameter. Similarly, we have a default parameter to give some default value to attribute. To set the access for an attribute we have access parameter where we can specify public, private, global access for an attribute. By default, the attribute have public access.
To make the attribute required we have required parameter where we can set true or false.
Let start with the basic attributes,
1) Boolean
Syntax:
<aura:attribute name="Anyname" type="Boolean" />
We can use the boolean attribute when we want to store boolean results.
2) Integer
Syntax:
<aura:attribute name="Anyname" type="Integer" />
We can use the integer type attribute for storing integer type values.
for ex: 1,2,3 etc.
3) String
Syntax:
<aura:attribute name="Anyname" type="String" />
We can store some text value inside the string type attribute.
ex: some text 1,some text2 etc.
4) Date
Syntax:
<aura:attribute name="Anyname" type="Date" />
Syntax:
<aura:attribute name="Anyname" type="DateTime" />
6) Double
Syntax:
<aura:attribute name="Anyname" type="Double" />
To store fractional values.
7) Decimal
Syntax:
<aura:attribute name="AnyName" type="Decimal" />
Decimal is better than Double for maintaining precision for floating-point calculations. It’s preferable for currency fields.
8) Long
Syntax:
<aura:attribute name="AnyName" type="Long" />
Long values can contain numbers with no fractional portion. Use this data type when you need a range of values wider than those provided by Integer.
We can use arrays for each of these basic types.
As an example,
<aura:attribute name="fruitsList" type="String[]" default="['apple','mango','orange']" />
No comments:
Post a Comment