Thanks Dan, I went with your suggestion and now have the search parameters in the URL. This is what the URL looks like now:
localhost/#/customers?searchText=test&pageSize=25&pageNumber=1
..and here is my updated state in ui-router. The params section sets the default values and "squashes" the URL parameters if they match the defaults.
.state("app.customers", {
url: "/customers?searchText&pageSize&pageNumber",
params: {
searchText: { value: "", squash: true },
pageSize: { value: 25, squash: true },
pageNumber: { value: 1, squash: true }
},
controller: "customersController as vm",
templateUrl: "customers.html",
resolve: {
customerService: "customerService",
customers: function (customerService, $stateParams) {
if ($stateParams.searchText) {
return customerService.search($stateParams.searchText, parseInt($stateParams.pageSize), parseInt($stateParams.pageNumber));
} else {
//return empty array and default pager
return null;
}
},
}
})
..and now on the customer page when the user hits the search button I just do this in the controller's search() method.
$state.go("app.customers", { searchText: vm.searchText, pageSize: vm.pager.pageSize, pageNumber: pageNumber });
This UrlMatcher documentation for ui-router was very helpful. This article was also helpful.