Reputation: 1780
The query-params-new flag set to true.
Using latest ember and ember data. Ember: 1.6.0-beta.1+canary.b5b90241 ember.js and Ember Data : 1.0.0-beta.7+canary.b45e23ba
Application Adapter is set to this:
export default DS.RESTAdapter.extend({
host: 'http://example.com',
namespace: 'api/v2',
headers: {
"ClientId": "a-key",
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Headers": "X-Requested-With"
}
});
The locations route looks like this:
export default Ember.Route.extend({
model: function(params){
return this.store.find('restaurant');
}
});
The locations controller looks like this
export default Ember.ArrayController.extend({
queryParams: ['lat', 'lon', 'limit'],
lat: null,
lon: null,
limit: null,
});
Navigating to this url http://example.com/locations?lat=47.620508&limit=22&lon=-122.349174
Ember data sends http://example.com/locations
as the request.
I must be missing something?
Upvotes: 2
Views: 4267
Reputation: 51717
There are a few things you need to do to get query-params-new working as expected.
First, you say you're using the latest ember, but don't specify whether it's the latest stable release or the latest canary release (master). In order to use query-params-new, you need to use canary, which is just the master branch. It is not available in the stable or beta releases yet, but you can download it here.
Second, you need to specify in your controller which params you want to bind to the route. Your locations controller would need to look something like this:
export default Ember.ArrayController.extend({
queryParams: ['lat', 'lon', 'limit']
});
All of this is documented on the Ember site. http://emberjs.com/guides/routing/query-params/
Edit based on additional question info:
It looks like you're not using the params in your route. You can use findQuery
to send the params to the server like so:
export default Ember.Route.extend({
model: function(params){
return this.store.findQuery('restaurant', params);
}
});
Upvotes: 5