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:



<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.



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

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

for ex:1,2,3 etc.



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

You can store some text value inside string type attribute.

ex:some text 1,some text2 etc.



<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.



<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