Skip to content

Instantly share code, notes, and snippets.

@Sunil02kumar
Created June 25, 2017 10:38
Show Gist options
  • Select an option

  • Save Sunil02kumar/a806632678fa5e6264ebcb6a8d82fa1e to your computer and use it in GitHub Desktop.

Select an option

Save Sunil02kumar/a806632678fa5e6264ebcb6a8d82fa1e to your computer and use it in GitHub Desktop.
Passing component attribute value from VF page to Lightning component
<apex:page standardcontroller="Account" sidebar="false">
<apex:includeLightning />
<div id="compContainer" />
<!--Here here skforce in script is my org namespace. if you are not using namespace in your org,
then simply use c. like c:VFPageApp, c:VFPageComponent etc-->
<script>
$Lightning.use("skforce:VFPageApp", function() {
$Lightning.createComponent("skforce:VFPageComponent",
{PassesValueFromVF:"{!JSENCODE(Account.Name)}"},
"compContainer",
function(cmp) {
console.log("c:VFPageApp loaded successfully in VF page");
}
);
});
</script>
</apex:page>
<aura:application access="GLOBAL" extends="ltng:outApp">
<c:VFPageComponent/>
</aura:application>
<aura:component >
<aura:attribute name="PassesValueFromVF" type="string"/>
Account name Passed from VF Page: {!v.PassesValueFromVF}"
</aura:component>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment