I have a difficult problem that I could not solve for some time.
Essentially, when I am on a specific $routeone and I am doing one $state.go(routeName, params);, I need to add one parameteror more parametersto the URL.
Also, paying attention to the fact that the route can also be visited without any parameters, so it should be clean.
I would like to achieve this result:
- The actual address:
localhost:4000 - Required Address:
localhost:/4000/myRoute/myStuff/myParam - Avoid:
localhost:/4000/myRoute//if specified $state.go(myRoute)without parameters.
For instance:
$state.go(myRoute, {
param1 : 'myStuff',
param2 : 'myParam'
});
function myRoute($stateProvider) {
$stateProvider
.state('myRoute', {
url: 'myRoute/{param1}{param2}',
parent: 'myParent'
. . .
})
}
Will work, but gives localhost:/4000/myRoute/myStuffmyParam.
So, I tried to use /as a separator url: 'myRoute/{param1}' + '/' + '{param2}'
and it works fine, I get localhost:/4000/myRoute/myStuff/myParam.
, , / , .
, $state.go('myRoute') localhost:/4000/myRoute//, .
, , , , param1, , .
,
param1 : 'myStuff' + '/'param1 : 'myStuff' + '\/'param1 : 'myStuff/'param1 : 'myStuff\/'
URL localhost:4000/myRoute/myStuff~2FmyParam.
, , -, .
param1 : 'myStuff-' localhost:4000/myRoute/myStuff-myParam
{param} :param - . angular -ui/ui-router URL-
, URL-?. myRoute[/:param1[/:param2]] .
param1%2F 'param1' + '%2F' .
~2F %252f . decodeURI('%2F') .
.
.