I have this list of users .. When a user clicks in one of those user in the list.. it will redirect me to my profileState with the associated UID of the user. I use state parameters to pass the UID from the userListState to the profileState..
When i type
console.log($stateParams);
it displays the UID which i passed from userListState .. but once i refresh the page.. the UID will become null.. So i would like to know how you guys make that specific data remain there after page reload.
How do you have configured your states? becuase you should do something like
.state('app.profile', {
url: '/profile/:uid',
views: {
'@app': {
templateUrl: 'app/profile/index.html',
controller: 'ProfileController as profileCtrl'
}
},
params: {
uid: null
}
})
this way when you go to your state you'll end up with
localhost/profile/234
you will refresh and uid will be there.
There are 2 common ways to store your uid:
Assign variables to $rootScope, that way its visible to all the controllers
localStorageService , this will hold the values even after user refreshes the page.