Tuesday, September 4, 2018

Basic Attributes type in Salesforce Lightning

Attributes act like a variable to store different types of values.
Name and type are parameter of attribute which are always required in attributes,description is another parameter where we can mentioned about description of attribute.Description is not an required attribute.Similarly we have default parameter to give some default value to attribute.To set the access for an attribute we have access parameter where we can specify about 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.

Basic Attributes:1) Boolean   


<aura:attribute name="Anyname" type="Boolean" />

You can add default values by adding default="true" inside aura tag.

You can use the boolean attribute when you want to have true or false value stored.

2) Integer


<aura:attribute name="Anyname" type="Integer" />

You can use the integer type attribute for storing integer  type values.

for ex:1,2,3 etc.

3) String


<aura:attribute name="Anyname" type="String" />

You can store some text value inside string type attribute.

ex:some text 1,some text2 etc.

4) Date


<aura:attribute name="Anyname" type="Date" />

Note:The format of date captured will be in yyyy-mm-dd.

5) DateTime


<aura:attribute name="Anyname" type="DateTime" />

To store date time.

6) Double


<aura:attribute name="Anyname" type="Double" />

To store fractional values.

7) Decimal


<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


<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