Reputation: 5089
I have a simple web application that is just a table that displays data. You can apply searches and filters to the table, and it updates the URL so others can go to the website and see the data in the same manner. The filtering works perfectly, but I am a bit lost on how to go about implementing the search.
The table's data is entirely dynamic, so I have no idea how many columns/rows there will be or what they will be. You can search each column individually or together.
Since there are a dynamic number of columns, I couldn't possibly make a $stateParam
for each one. The search for all of the columns are stored in an object with the keys as the column name and the search value for the column as the respective value for the key.
Here would be a sample search object:
var search = {column1:'searchvalue1',column2:'searchval2'...etc}
I wanted to do something like:
$stateProvider.state("filter", {
url: '/column/:column/search/{search}?column1&column2/',
parent: 'parentState',
controller: 'Ctrl'
});
But since the columns are dynamic, I would like to just be able to have the search object passed, so the keys are the column1 or column2, and the values are the = after them. Is there a way to do this? I can't find any examples/docs.
Upvotes: 0
Views: 160
Reputation: 3108
No you can't pass an arbitrary list of state parameters. $stateParams
will only contain those parameters that are listed in your state definition.
You will most likely want to just pass your object as a JSON string. You can use JavaScript functions: encodeURIComponent()
and decodeURIComponent()
Upvotes: 1