You need to sign in to do that
Don't have an account?
Herish Surendran
I want to navigate from one lightning component to another component (RegistrationFormTutorial). I have written the above code. But I am getting error like this:
" This page has an error. You might just need to refresh it. Action failed: c:HtmlTryout$controller$navigate [Cannot read property 'setParams' of undefined] Failing descriptor: {c:HtmlTryout$controller$navigate} "
Could anyone please help me on this. Thanks in advance.
How to navigate from one lightning component to another
({ navigate : function(component, event, helper) { var navigateEvent = $A.get("e.force:navigateToComponent"); navigateEvent.setParams({ componentDef: "c.RegistrationFormTutorial" }); navigateEvent.fire(); } })
I want to navigate from one lightning component to another component (RegistrationFormTutorial). I have written the above code. But I am getting error like this:
" This page has an error. You might just need to refresh it. Action failed: c:HtmlTryout$controller$navigate [Cannot read property 'setParams' of undefined] Failing descriptor: {c:HtmlTryout$controller$navigate} "
Could anyone please help me on this. Thanks in advance.
If you are trying e.force:navigateToComponent in Lightning Application then you will get this error message. Most of the Lightning events will not work in Lightning Application.
If you are trying the same component in record Page or in home page then it will work.
Otherwise lightning:navigation service.
Thanks,
Maharajan.C
All Answers
Try the below one:
In the componentDef you have to use the colon after namespace not the dot operator.
({
navigate : function(component, event, helper) {
var navigateEvent = $A.get("e.force:navigateToComponent");
navigateEvent.setParams({
componentDef: "c:RegistrationFormTutorial"
});
navigateEvent.fire();
}
})
https://developer.salesforce.com/docs/component-library/bundle/force:navigateToComponent/documentation
Thanks,
Maharajan.C
No. It didn't help
" This page has an error. You might just need to refresh it. Action failed: c:HtmlTryout$controller$navigate [Cannot read property 'setParams' of undefined] Failing descriptor: {c:HtmlTryout$controller$navigate} "
If you are trying e.force:navigateToComponent in Lightning Application then you will get this error message. Most of the Lightning events will not work in Lightning Application.
If you are trying the same component in record Page or in home page then it will work.
Otherwise lightning:navigation service.
Thanks,
Maharajan.C