I am using one main lightning component and all other components are opening within the main components. I want to update the browser URL when the user navigates. I am trying to navigate to a component in the community to update the URL. But it's not working. I used below code:
var pageReference = {
"type": "standard__component",
"attributes": {
"componentName": "c__Target"
},
};
navService.generateUrl(pageReference)
.then($A.getCallback(function(url) {
cmp.set("v.url", url ? url : defaultUrl);
}), $A.getCallback(function(error) {
cmp.set("v.url", defaultUrl);
}));
In the community it gives null value in url but in salesforce lightning its working fine.
I have also tried this but it didn't https://rajvakati.com/2018/11/13/navigate-to-component-using-lightningnavigation/
comm__namedPagetype pageReference works. Please read the answer carefully here – salesforce-sas Sep 25 '19 at 17:57