Currently, I am passing an id to a new state using $stateParams which works well. However, the issue arises when the user reloads the page since there won't be any values in $stateParams. To solve this problem, I decided to store the $stateParam id in localStorage upon initial page load. In case of a reload, if the id from $stateParams is not present, it can be manually assigned. See example below:
// Make sure params are set upon page reload
if (!$stateParams.id) {
$stateParams.id = localStorageService.get('campaignId');
$state.go($state.current, $stateParams);
}
This method works on my local machine, but throws an error on my development server:
Cannot assign to read only property 'id' of object '#<Object>'
.
I'm wondering if there is a way to make $stateParams writable?
Thank you in advance for your assistance.