I've encountered an issue where I need to pass a parameter from one controller to another without it being visible in the URL. I attempted to do so with the following code:
this.router.navigate(['/collections/'+this.name], {id: this.id});
However, I'm unable to access the parameter on the other controller. I also tried the following approach:
{
path: 'collection/:city',
component: Component,
data : {id : null}
}
But my question is, how can I dynamically pass the id since it's not available in the routing file? Is there a way to pass it from the component?
In AngularJS 1.5, we utilized the params hash to conceal the id from the URL.
$state.go('collection', {id: 10})
state('collection', {
url : '/collection',
params : {
id : null,
},
templateUrl : templatesDir + 'collection.html',
controller : 'collectionController',
})
My question now is whether there is a similar method in AngularJS 2.
Thank you!