Newer Version Available

This content describes an older version of this product. View Latest

force:navigateToComponent (Beta)

Navigates from a Lightning component to another.

This release contains a beta version of force:navigateToComponent with known limitations.

Note

To navigate from a Lightning component to another, specify the component name using componentDef. This example navigates to a component c:myComponent and sets a value on the contactName attribute.

1navigateToMyComponent : function(component, event, helper) {
2        var evt = $A.get("e.force:navigateToComponent");
3        evt.setParams({
4            componentDef : "c:myComponent",
5            componentAttributes: {
6                contactName : component.get("v.contact.Name")
7            }
8        });
9        evt.fire();
10    }

You can navigate only to a component that’s marked access="global" or a component within the current namespace.

This event is handled by the one.app container. It’s supported in Lightning Experience and Salesforce1 only.

Note

Attribute Name Type Description
componentDef String The component to navigate to, for example, c:myComponent
componentAttributes Object The attributes for the component
isredirect Boolean Specifies whether the navigation is a redirect. If true, the browser replaces the current URL with the new one in the navigation history. This value defaults to false.