You need to sign in to do that
Don't have an account?
Renuka kamble 10
Hi All, I want to open another lightning component on click of button. Please help in this.
I am trying to open another component on click of button but i am getting error as "Cannot read property 'newComponentAsync' of undefined".
Below is my code-
Component-
<button class="slds-button slds-button--neutral" onclick="{!c.gotoURL}">Open Another Component</button>
Controller-
gotoURL : function(component, event, helper) {
var destination ="markup://c:SampleComponent";
$A.componentService.newComponentAsync(this,
function(view) {
var content = component.find("content");
content.set("v.body", view);
},
{
componentDef: destination,
}, component);
}
Please help.
Below is my code-
Component-
<button class="slds-button slds-button--neutral" onclick="{!c.gotoURL}">Open Another Component</button>
Controller-
gotoURL : function(component, event, helper) {
var destination ="markup://c:SampleComponent";
$A.componentService.newComponentAsync(this,
function(view) {
var content = component.find("content");
content.set("v.body", view);
},
{
componentDef: destination,
}, component);
}
Please help.
please go through this below link
https://force-base.com/2016/11/06/lightning-components-navigation-re-defined-in-winter17-woooo-hooooo/
https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/ref_force_navigateToComponent.htm
Happy Lightning learning.