I wanted to define a route that received one mandatory param and another optional param that would be hidden in the URL. It would be something like:
http://www.myapp.com/viewingPodcast/4
and the hidden param still available but not shown in the URL.
I am using ng-href + $state.href to get the url.
I also have looked at this answer and it's comments but I still couldn't get it to work with my version.
This is my state config
.state("viewingPodcast", {
...
url: "/podcast/:id",
controller: "podcastCtrl",
templateUrl: ...,
params: { zineId: null },
data: {
...
},
resolve: {
...
},
})
And the $state.href:
...
$state.href("viewingPodcast", { id: content.id, zineId: content.zineId });
...
Both values (id and zineId) are not nulled when debugging the $state.href line.
I tried, like mentioned in the comments of the answer above:
$state.href("viewingPodcast", { id: content.id, zineId: { zineId: content.zineId } });
but when entering the controller and checking the params (with $state.params.zineId) the value is null.
I don't know if I'm doing something wrong and I still can't comment to ask on the other answer so I'm stuck creating a new question.
Thanks in advance