Lightning components are the basic building blocks of developing an application in the Salesforce1 platform. They intertwine each other and form an app in the Salesforce1 platform.

So, Let’s look at how to build a basic lightning component.

Below are the Steps to be followed to build your lightning component.

Steps

  1. Go to the Developer Console.
  2. Go to File –> New –> Lightning Component.
  3. Provide a Name and Description to your Component.
  4. Click Submit.
  5. Your Lightning component has now been created.

 

Put the below snippet in your component and Save the Component.

LightningComponent1.cmp


<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes">
Welcome to the world of Lightning ! ! !
</aura:component>

The above code simply prints the text “Welcome to the world of Lightning”. Note that I have implemented two interfaces in this component. The force:appHostable  and flexipage:availableForAllPageTypes interfaces. They are used for the below purposes.

  • force:appHostable – Allows a Lightning Component tab to be created against this component. This allows the component to be created as a stand-alone tab in the Salesforce UI.
  • flexipage:availableForAllPageTypes – This allows the component to be made accessible in the Lightning App builder. If this interface is not implemented, then the component cannot be accesses in Lightning App builder.

Now, follow the below steps so that your component appears in the Salesforce1 Navigation tab.

Steps

  1. Goto Setup > tabs > Create new tab in the Lightning Component tabs section
  2. Create the new tab as seen in the screenshot below.

p1

Now that we have created a tab for the component, let’s go ahead and follow the below steps to add the tab into a custom app.

Steps

  1. Goto Setup –> App Manager –> New Lightning App
  2. Select the appropriate Lightning tab and then assign it to the appropriate profile.
  3. In our case, just select the FirstLightningComponent and assign it to System administrator profile.
  4. Click Save.

 

 

Now, simply go to the App Launcher in your lightning interface  and select the Lighting app which you have just created.

p1

It should be rendered as seen in the below screenshot.

p1

 

 

Advertisements