Newer Version Available
force:navigateToComponent (Beta)
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.
| 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. |