I have a route:
.state('list', {
url:'/list?query',
templateUrl: '/views/list.html',
controller: 'ListCtrl as vm'
})
Is there a way to ensure a default value for the query?
I don't want to do it in the controller, as I use the same controller for other routes, and the controller has certain behaviour if the query
is undefined.
What I want is this particular route to default that query
.
In the old angular route I have done this sort of thing...
.when('/list',
templateUrl: '/views/list.html',
controller: 'ListCtrl'
controllerAs:true,
redirectTo:function(routeParams, path, search) {
if(!search.query) {
return "list?query=defaultSearch";
}
}
})