Sunday, June 25, 2017

Passing Lightning Component attribute value from VF page

As we know that we can include Lightning component in VF page by creating a Lightning App and add it to VF page by specify particular script. Sometime it is required to pass some dynamic value to component so that it can behave differently based on component attribute value.

Below is sample code which explains how to passed component attribute from VF page. Here we are passing Account name to lightning component by using standard controller on VF page.

In order to test the output, open below URL:
https://your-domain-url/apex/lightningVF?id=xxxxxxxxx

where xxxxxxxxx is Account Id.

Note:
  • Whenever you use extends="ltng:outApp" in Lightning app,  SLDS is automatically get applied your components.
  • If you don't want to apply SLDS, just use extends="ltng:outAppUnstyled"
  • If you are having org namespace, then always use " <namespace>:lightningComponentName" instead of  "c:lightningComponentName"  in VF page.

Hope this will help!!

6 comments: