Description
I have the following problem:
I have a state which may has a parameter called view
which results in a subset of items in a list, if the param is not set it will show all items
so i do have one url which is items
which can also be items?view=1
.state('items', {
url : '/items?view',
views: {
"mainPanel" : {
templateUrl : 'directives/items.html',
controller : function($scope, $stateParams) {
$scope.viewId = $stateParams.view;
}
}
}
})
I know have a navigation which i create from the database
ul.nav
li(ui-sref-active="active")
a(ui-sref="'items'") All items
li(ng-repeat="view in views", ui-sref-active="active")
a(ui-sref="items({ 'view' : {{ view.id }} })") {{ view.name }}
The problem now is if i got to a view with the view
param set the ui-sref
path for All items has also the param as i cannot set it to null.
I could set it in the all route by using { 'view' : null }
but this would make the route ugly and is not the desired behaviour.
Any idea how to reset the state params or how to provide a solution to this? I would like to have a way like ui-sref="'items({})'"
for resetting the params, otherwise i would have to use href
for now and loose the comfort of ui-sref-active