aura:component
1. it is a functional unit of aura which can contain
i. html
ii. standard or custom
2. file extension *.cmp
3. the bundle contains below elements
Component Type | Purpose |
---|---|
Component | XML |
Component Controller | Client side controller |
Helper Javascript | Client side controller (common set of js) |
Style CSS | Style code and Classes |
Documentation | Documentation |
Renderer Javascript |
Renderer |
SVG Icon |
Icon element |
4. Attributes
1. access : scope of the component
public : default one used to expose the component within namespace only.
global : can be used within namespace and outside the namespace
2. controller : to refer an apex class
3. description : to include the comment
4. extends : specifying the extending the application
eg.,
<aura:component extends=”namespace:componentName”>
5. extensible : it is a boolean value which says your current application can be extendable or nor
eg.,
<aura:component extensible=”true”>
6. template : specifiy the name of the custom template
7. implements : used to specify the list of interface
Navigation
Setup -> Developer Console -> File -> New -> Lightning Component.
Example 1
Name : Comp_one.cmp
<aura:component >
<h1>Ameerpet</h1>
<h1>Contact: 9969696699</h1>
</aura:component>
Include the above component into an application like below. This is mandatory to preview the component. A component can not be previewed.
<aura:application >
<h1>SFDC Lightning Training</h1>
<c:Comp_one/>
</aura:application>
Example 2
StudentPersonal.cmp
<aura:component >
<h1>Student Name: Ranjith Krishnan</h1>
<h1>Age: 30</h1>
<h1>Phone: 9840409993</h1>
</aura:component>
StudentAddress.cmp
<aura:component >
<h1>Anna Nagar</h1>
<h1>Chennai</h1>
<h1>Tamil Nadu</h1>
<br/>
<c:StudentCourse/>
</aura:component>
Preview the component using application
<aura:application >
<c:StudentPersonal/>
<br/>
<c:StudentAddress/>
</aura:application>
Components can also be nested
StudentCourse.cmp
<aura:component >
<h2>Salesforce Lightning Course</h2>
</aura:component>
StudentAddress.cmp
<aura:component >
<h1>Anna Nagar</h1>
<h1>Chennai</h1>
<h1>Tamil Nadu</h1>
<br/>
<c:StudentCourse/>
</aura:component>