Utilizing fromState
and fromParams
within the $stateChangeSuccess
event allows us to access all details regarding the previous location. This concept is elaborated in the following discussion:
Angular - ui-router get previous state
$rootScope.$on('$stateChangeSuccess', function (ev, to, toParams, from, fromParams) {
});
Is there a convenient means to extract this information into the URL or location format? For instance:
State: /page/:id/paragraph/:line
Params: id and line, etc..
Desired output:
/page/3/paragraph/5 ...
Maintaining clarity with numerous params could become complex. Additionally, AngularJS ui-router might utilize {{ id }}
as params rather than :id
. Is there an existing method for handling this situation, or must we resort to using RegEx? If so, what would be the appropriate RegEx string?
Appreciate any insights.