function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Law KumarLaw Kumar 

can navigate and save together on same button in lWC?

Hi, I want to build a component which has a saves button on its UI.
And when i hit the button ,it's together navigate to the next component and save the data on first one.
Best Answer chosen by Law Kumar
Danish HodaDanish Hoda
Hi Law,
To Navigate from one LWC to another, you need to get these steps:
  • Apply NavigationMixin to the landing LWC, say baseLWC.
  • Create an aura:component, say auraCMP, which implements lightning:isUrlAddressable inteface
  • Call/Embed another LWC from this aura:component like the same you add another child component as below
    • <c:navigateToLWC /> 
  • Use Navigation service on baseLWC to navigate to the standard component to auraCMP as below:
    • this[NavigationMixin.Navigate]({
                  type: 'standard__component',
                  attributes: {
                      componentName: 'c__auraCMP'
                  }
});

All Answers

Danish HodaDanish Hoda
Hi Law,
To Navigate from one LWC to another, you need to get these steps:
  • Apply NavigationMixin to the landing LWC, say baseLWC.
  • Create an aura:component, say auraCMP, which implements lightning:isUrlAddressable inteface
  • Call/Embed another LWC from this aura:component like the same you add another child component as below
    • <c:navigateToLWC /> 
  • Use Navigation service on baseLWC to navigate to the standard component to auraCMP as below:
    • this[NavigationMixin.Navigate]({
                  type: 'standard__component',
                  attributes: {
                      componentName: 'c__auraCMP'
                  }
});
This was selected as the best answer
Law KumarLaw Kumar
Thanks. Danish Hoda