Contents
How to create a lightning tab in force?
If you create a Lightning component tab and associate it directly with the component, this event lets you navigate to the tab associated with the target component. To create a Lightning component tab and associate it with the component, from Setup, enter Tabs in the Quick Find box, and then select Tabs.
And there is no proper way to inform Container component about changes in url. IMHO when we use standard lightning navigation like that, lightning framework should always refresh components and run doInit method, if its there, I count this as a bug. If I am wrong guys, just give me an example how to handle this situation :).
How does a lightning event work in Salesforce?
When fired from a component embedded in Lightning Experience or Salesforce app, the app creates and renders the target component in the app content area, replacing the current content. If you create a Lightning component tab and associate it directly with the component, this event lets you navigate to the tab associated with the target component.
You can navigate only to a component that’s marked access=”global” or a component within the current namespace. Don’t depend on the URL generated by this event. It appears in the browser location bar and can be bookmarked, but the URL isn’t permanent. This event is handled by the one.app container.
Lightning component navigation has been re-defined in Winter’17 and we now have a native event to navigate through components. Suppose you have a component named as MyComponent2.cmp and you want to navigate to this component from one of your existing components, then you can do it like this
How to navigate from one component to another in Salesforce Lightning?
In the above controller of Component1, we are capturing the user inputs, converting it to integer data type, adding the two values and again converting it back to String data type. The final result is then passed to the “NavigateToC2” event and fired. Now, we need to define the Component2, which will display the result.