SalesforceBlue

Feel the rhythm of Salesforce

Aura

Aura Component Attributes Simplified

Aura attributes are like variables in Apex which stores certain data types.

Let’s understand the Attributes Types with a game of cricket 🙂

Boolean

It stores either True or False.

<aura:attribute name="isCricketMatchToday" type="Boolean" />
Date

It stores a date value that corresponds to a calendar day in the format yyyy-mm-dd. 

<aura:attribute name="finalsDate" type="Date" />
DateTime

It stores a DateTime value. It corresponds to a timestamp.

<aura:attribute name="matchTimings" type="DateTime" />
Double

It stores a decimal number(A number with a decimal point).

<aura:attribute name="runRate" type="Double" />
Decimal

It also stores a decimal number. It is better than double for maintaining precision and is a preferred type for storing currency values.

<aura:attribute name="ticketsEarnings" type="Decimal" />
Integer

It stores a number without any decimal point.

<aura:attribute name="matchScore" type="Integer" />
Long

It stores a number without any decimal point. This type can store more values than Integer can hold.

<aura:attribute name="ticketSold" type="Long" />
String

It stores a sequence of characters.

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

Below we cover the non-Basic Types of attributes:

Id

It stores the salesforce record Id.

<aura:attribute name="currentBatsmanRecordId" type="Id" />
Arrays

It stores an array of common Types.

<aura:attribute name="OpeningBatsman" type="String[]"/>
Object

It can store any other basic type or a type that is an instance of an Object.

<aura:attribute name="matchStats" type="Object" />
sObject

It stores sObject data either a standard object or a custom object.

Below we have declared an attribute holding a custom object Player__c.

<aura:attribute name="playerData" type="Player__c"/>

Here we covered the attributes and what type of values they can store.

You should be aware of how to use them in Aura Component by setting and getting their values.

You can learn about it here – Get And Set Aura Attributes

Thank you for visiting SalesforceBlue.com
If you have any queries feel free to write down a comment below 🙂


Leave a Reply

Your email address will not be published. Required fields are marked *