Skip to content

Instantly share code, notes, and snippets.

@Sunil02kumar
Created July 12, 2018 17:26
Show Gist options
  • Save Sunil02kumar/6ae98404cb29a4666b87e8c3294b97d9 to your computer and use it in GitHub Desktop.
Save Sunil02kumar/6ae98404cb29a4666b87e8c3294b97d9 to your computer and use it in GitHub Desktop.
Adding Lightning Components in VF Page and Passing Values from URL
<aura:application extends="ltng:outApp" >
<aura:dependency resource="c:SK_LightningCmpForVF"/>
</aura:application>
<aura:component >
<aura:attribute name="ltngPassedInfoFromVF" type="string"/>
<aura:attribute name="ltngPassedAccountNameFromVF" type="string"/>
<div style="background-color:#E6E6FA;border-style: solid;height:200px;margin:5%;padding:2%;">
<div class="slds-align--absolute-center">
This is SK_LightningCmpForVF Component
</div>
<br/>
Display Account Name passed from VF page:-<b>{!v.ltngPassedAccountNameFromVF}</b>
<br/>
Display info passed from VF page:-<b>{!v.ltngPassedInfoFromVF}</b>
</div>
</aura:component>
<apex:page standardController="Account" sidebar="false" standardStylesheets="false">
<apex:includeLightning />
<div id="componentContainer" />
<script>
var infoString = "{!JSENCODE($CurrentPage.parameters.infoString)}";
$Lightning.use("c:SK_LightningAppForVF", function() {
$Lightning.createComponent("c:SK_LightningCmpForVF",
{
ltngPassedAccountIdFromVF: "{!JSENCODE(Account.Name)}",
ltngPassedInfoFromVF : infoString
},
"componentContainer",
function(cmp) {
console.log("SK_LightningAppForVF loaded successfully in VF page");
}
);
});
</script>
</apex:page>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment