1.2 Write a Hello world lightning component

In the previous post, we have mentioned lightning component is the replacement of Visualforce pages in lightning experience. So today, we are going to write our first lightning component.

The code

Let’s create a new lightning component by File > New > Lightning component in developer console. Or just create one in your favourite IDE. Name the lightning component as HelloWorldCmp

    Hello World!

And in our HelloWorldApp, update the code into:

<aura:application >

Save it and try it out!

A little bit explanation

It is easy to understand the code. For a lightning component, you just need to embed everything inside aura:component.

And the grammar to call such a component is also very simple. If you are coming from a Visualforce background, you will notice that the grammar is very similar to Visualforce component. You can simply reference the component by using c:[componentName]. If your org has a namespace prefix, don’t forget to change c: into [yourNamespace]:

Next Post

1.3 Apply styling to lightning component

Subscribe to Sfdcinpractice

Subscribe to get the latest blogs and tutorials of sfdcinpractice. No spam, no trash, only the awesome posts from sfdcinpractice. 

Leave a Reply

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