January 31, 2017 by LanceShi
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.
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
<aura:component> Hello World! </aura:component>
And in our HelloWorldApp, update the code into:
<aura:application > <c:HelloWorldCmp/> </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]: