Reputation: 1955
I am building a route meant to take in several query params, one of which is a Hash:
http://www.test.com/foo/bar?first_name=Johnny&hashparam[][foo]=bar
Controller:
export default Ember.Controller.extend({
queryParams: ["first_name", "hashparam"]
});
Route:
export default Ember.Route.extend({
model(params) {
console.log(params.first_name);
console.log(JSON.stringify(params.hashparam));
}
});
For the above example request, "Johnny" is successfully logged to the console, but the second logs "undefined". I debugged into the code and see that params
includes a key for hashparam
but its value is undefined
. I can't figure out why because from what I can tell, the request above is using the correct format to pass in a hash key and value. I also added a beforeModel
hook to my route so I can investigate the incoming Transition
and I see that queryParams
includes a key named hashparam[][foo]
with value 'bar'
.
What's wrong here? Am I doing something wrong?
Upvotes: 0
Views: 141
Reputation: 458
You are not providing a key of hashparam
, you are providing a key of hashparam[][foo]
.
Upvotes: 1