How can I set a query parameter in AngularJS without doing a route?
In your $routeProvider configuration set reloadOnSearch
to false:
$routeProvider
.when('/items', {
controller: 'ItemsCtrl',
templateUrl: '/templates/items',
reloadOnSearch: false
},
...
);
and in your controller use $location.search()
to set the id
param:
$location.search('id', 123);