I am trying to pass a user_id parameter with the url and then retrieve it on the other page by calling $location.search()) in the controller of that page.
This works in my browser, but when i test on my android phone it seems to have a problem.
The first time the link is clicked it goes to the correct page and the user_id is retrieved, but if i navigate away from the user-profile page and then press the back button to return to it, the url parameter is not available.
Am i trying to do the wrong thing? Should i be using some other method ?
href="#/user-profile?user_id={{user.user_id}}">
Well i solved this issue by setting up parameters in angular ui-router.
This way you can retrieve the parameters using $stateParams even when you go back in history.
Keep in mind that using $location.path to redirect the page and trying to retrieve the parameters using ($location.search()).paramName will work in the browser even when going back in history, but will fail on the actual device.
Why use a query param at all?
Perhaps this instead:
ui-sref="user-profile({userId : user.user_id}):
.state('user_id', {
url: '/user_id/:userId',
templateUrl: 'templates/user_detail',
controller : 'UserDetailController'
})
Yeah your right this is more appropriate. Thanks!