This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In the below example we are passing sObject data i.e. acc the helper from there to controller fom there to component. | |
In the component when we initialized the attribute we didn't sepecify default as default="{'sObjectType':'Account'}" | |
because we are getting the acc data from Apex and we are sure that we are getting Account data only hence we didn't initialized. | |
<aura:handler name="init" value="{!this}" action="{!c.callMe}" /> -- Same as constructer. In this example we have only shown one record | |
if we want to display multiple records either we need to go for data table / iterator. | |
Component | |
************************************************************************************************************ | |
<aura:component controller="Example_Four"> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Component | |
************************************************************** | |
<aura:component controller="classWithParameters"> | |
<aura:attribute name="name" type="String" /> | |
<aura:attribute name="phone" type="String" /> | |
<aura:attribute name="industry" type="String" /> | |
<aura:attribute name="type" type="String" /> | |
<aura:attribute name="result" type="String" /> | |
<aura:attribute name="flag" type="Boolean" default="true"/> | |
<aura:attribute name="flag1" type="Boolean" default="false"/> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. If you want to invoke any apex class in the in the lightning component | |
then the class should have @AuraEnabled methods or variables in it. | |
2. How to define a apex class | |
public with sharing class ClassName{ | |
@AuraEnabled methods | |
@AuraEnabled variables | |
} | |
3. if you want to invoke any apex method in the lightning component then | |
a.Method should be annotated with @AuraEnabled |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
If there is any reusable code available then we will keep the code in helper and use it in controller | |
We can't directly call helper methods from component | |
Helper methods runs in different threads. Hence better performance | |
Component | |
******************************************************************************************************* | |
<aura:component > | |
<aura:attribute name="empName" type="String" /> | |
<aura:attribute name="age" type="Integer" /> | |
<aura:attribute name="salary" type="Decimal" /> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
To display Array of elements ot lists or set we can use iteration in lightning. | |
<aura:iteration items="{!v.student}" var="a"> | |
items -- data on which we need to iterate | |
var -- The name of the variable to use for each item inside the iteration | |
aura:iteration iterates over a collection of items and renders the body of the tag for each item | |
Component | |
********************************************************************************** | |
<aura:component > | |
<aura:attribute name="student" type="List" default="['ABC','DEF','GHK','LMN','OPQ']" /> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
A lightning:layout is a flexible grid system for arranging containers within a page or inside another container. | |
The default layout is mobile-first and can be easily configured to work on different devices. | |
A lightning:layoutItem is the basic element within lightning:layout. | |
You can arrange one or more layout items inside lightning:layout. | |
The attributes of lightning:layoutItem enable you to configure the size of the layout item, | |
and change how the layout is configured on different device sizes. | |
>> we need to use multipleRows="true" in order to get the benifit of lightning:layoutItem | |
>> default size is 12 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
When you are initializing sObject like below | |
<aura:attribute name="acc" type="Account" /> --> This is like Account acc; There is no memory allocation happened | |
hence while entering values we will get null issue. | |
"TypeError: d is null | |
throws at https://domain.lightning.force.com/auraFW/javascript/5fuxCiO1mNHGdvJphU5ELQ/aura_prod.js:544:409" | |
Correct way of initializing is |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
aura:if evaluates the isTrue expression on the server and instantiates components in either its body or else attribute. | |
Only one branch is created and rendered. Switching condition unrenders and destroys the current branch and generates the other | |
<aura:if isTrue="{!v.truthy}"> | |
If true process this piece of code | |
<aura:set attribute="else"> | |
If false process this piece of code | |
</aura:set> | |
</aura:if> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I have got this strange doubt when we can read the values based on ids what is the use of <aura:attribute> | |
For displaying the data we can use output text. In this case we are reading and assigning the values in script i.e. controller. | |
In order to display values in markup i.e. component we need attributes | |
Component | |
************************************************************************************************ | |
<aura:component > | |
<aura:attribute name="FirstName" type="String" /> | |
<aura:attribute name="LastName" type="String" /> | |
<aura:attribute name="DateOfBirth" type="Date" /> |