I have a lightning component which retrieve/update some account details.
I want to call this component from a quick action. In order to call it from a quick action I need this to be in a VF page.
Is there a way to directly access this component (without calling the application) in a VF page? (I do NOTneed to load the component through a domain->application)
I tried below code but it shows me just a blank page. Could some one please help me with this.
Please see the code below
visualForce page (I need the component to be displayed inside this VF page)
<apex:page >
<apex:includeScript value="/lightning/lightning.out.js" />
<apex:includeLightning />
<div id="lightning" />
<script>
$Lightning.use("c:AccountsList", function() {
$Lightning.createComponent("AccountsListTest",
{ label : "Press Me!" },
"lightning",
function(cmp) {
var test = 'test';
alert(test);
});
});
</script>
Apex Controller Class
public class AccountsController {
@AuraEnabled
@RemoteAction
public static List<Account> getAccounts() {
return [SELECT id, Name, Industry, CreatedDate
FROM Account
ORDER BY createdDate DESC];
}
}
AccountsList lightning Component
<aura:component controller="AccountsController">
<aura:attribute name="accounts" type="List" />
<aura:handler name="init" value="{!this}" action="{!c.doInit}" />
<!-- Use the Apex model and controller to fetch server side data -->
<table class="slds-table slds-table--bordered slds-table--striped">
<thead>
<tr>
<th scope="col"><span class="slds-truncate">ID</span></th>
<th scope="col"><span class="slds-truncate">Name</span></th>
<th scope="col"><span class="slds-truncate">Type</span></th>
<th scope="col"><span class="slds-truncate">Number Of Employees</span></th>
<th scope="col"><span class="slds-truncate">Ticker Symbol</span></th>
<th scope="col"><span class="slds-truncate">Phone</span></th>
<th scope="col"><span class="slds-truncate">Details</span></th>
</tr>
</thead>
<tbody>
<aura:iteration items="{!v.accounts}" var="account">
<tr>
<td>{!account.Id}</td>
<td>{!account.Name}</td>
<td>{!account.Type}</td>
<td>{!account.NumberOfEmployees}</td>
<td>{!account.TickerSymbol}</td>
<td>{!account.Phone}</td>
<td>
<c:button class="slds-button slds-button--neutral"
label="Details"
svgXlinkHref="/resource/slds0120/assets/icons/standard-sprite/svg/symbols.svg#account"
svgClass="slds-icon slds-icon-text-default"
onclick="{!c.showDetails}"
data="{!account.Id}"
/>
</td>
</tr>
</aura:iteration>
</tbody>
</table>
</aura:component>
Controller.js
({
doInit : function(component, event, helper) {
//Fetch the expense list from the Apex controller
helper.getAccountList(component);
},
showDetails: function(component, event, helper) {
//Get data via "data-data" attribute
alert(event.target.getAttribute("data-data") + " was passed");
}
})
Helper.js
({
//Fetch the accounts from the Apex controller
getAccountList: function(component) {
var action = component.get("c.getAccounts");
//Set up the callback
var self = this;
action.setCallback(this, function(actionResult) {
component.set("v.accounts", actionResult.getReturnValue());
});
$A.enqueueAction(action);
}
})
Thanks in advance.