I have a search from with multiple optional fields, I don't feel I've handled this correctly in the past and want to know how to correctly handle this so that results will reload should a user refresh the page after going through the search form.
I have a form that people can use to search for clients, my users can search by type, name, account number
type is a required field
name and account number are optional fields.
I can use the $routeProvider to configure my routes something like:
.when('/clientSearch/:type/:accountNumber?/:name?', {
but if account number and name are optional how do I distinguish if only one of the two is being passed in? Some forms have multiple optional numeric/string fields.
Using $location.search() I can set the URL params, like:
$location.search( {type: type, accountNumber: accountNumber, 'name': name} )
Which is the preferred method, coming at this wrong?
How do you properly handle search forms and allow the same results to be fetched again if the page is refreshed?