+ Start a Discussion
Herish SurendranHerish Surendran 

How to navigate from one lightning component to another component

({
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.
Best Answer chosen by Herish Surendran
Devi ChandrikaDevi Chandrika (Salesforce Developers) 
Hi herish,
Maybe you are try it with lightning app.app, it is supported only with salesforce1 or Lightning Experience.You can navigate only to a component that’s marked access="global" or a component within the current namespace. 

Try adding your component to the salesforce1 or Lightning Experience tab.

Please refer below link which might help you in this.
https://developer.salesforce.com/docs/component-library/bundle/force:navigateToComponent/documentation

Hope this helps you
If this helps kindly mark it as solved so that it may help others in future.

Thanks and Regards