Possible To Hide Some Parameters In Url With Angular Ui Router?
I want to pass two values to new ui-view via params: item id list of objects However, I'd like the new view to show only the id in the browser URL and not the stringified array o
Solution 1:
You are on the right path. To hide params you have to define them in params
as you do, without squash
.
Your example should look like:
$stateProvider.state('show', {
url:"/show?itemId",
views: {
'mainView': {
templateUrl:'views/itemView.html',
controller:'showController'//paramsdonotworkhere!Theyneedtobeattachedbelow...//$stateProvider.state('show', {url:'/show/:url_param',views:{}, params: {}})
}
},
resolve: {},
params: {
itemList: {
value:null
}
}
})
See example: http://plnkr.co/edit/wEjwCVWMKTyuSdyLr0og?p=preview
Solution 2:
It's also possible doing that
SomeController:
$state.go(someState, {
'itemId' : item._id,
'itemName' : item.title
});
SomeRoute function someRoute($stateProvider) {
$stateProvider
.state('someState', {
url : '/:itemName',
params : {
'itemId' : null//hides itemId param
}
});
}
Output:.../itemnumber1
Post a Comment for "Possible To Hide Some Parameters In Url With Angular Ui Router?"