Within my application, I have a parent state along with child states that belong to the parent. The parent state contains an optional parameter called reviewId. Currently, everything is functioning correctly - when I send the parameter in $state.go, the state opens as expected. However, I am looking to make a change when creating a new review (the reviewId is populated after a backend call).
Here is the URL for opening an existing review with the ID included:
http://localhost:3000/#/planning?reviewId=1000.
When creating a new review, the URL is:
http://localhost:3000/#/planning. After saving the review (with the ID populated), I want to append ?reviewId=newId to the URL without using state.go.
$stateProvider
.state('root.planning', {
url: '/planning?reviewId=',
abstract: true,
params: {
reviewId: null,
readOnlyMode: null,
locked: null,
editButton: null
},
reloadOnSearch:false,
views: {
'@': {
templateUrl: 'src/app/modules/planning/views/planning.tpl.html',
controller: 'PlanningMainController as reviewvm'
}
}
})
.state('root.planning.planning', {
url: '',
params: {
reviewId: null
},
data: {
planningChild: true,
stateTypeCd : "PLA"
},
reloadOnSearch:false,
templateUrl: 'src/app/modules/planning/views/tabs/tab.planning.view.html',
controller: 'PlanningController as planningvm'
})
UPDATE
I also attempted to update the reviewId in stateParams after accessing the ID and then calling $state.reload(). However, with this approach, stateParams.reviewId is null after the reload. I am wondering if there is a way to achieve this without triggering a reload.