Friday, 15 January 2010

query parameters - Ember.js: extract queryParams object -


I am using Amber's query parameters:

query parameters are dynamic, so the base controller Do not know what will be the property like ['q', 'page'] or ['q', 'foo', 'bar'] or any other Can be sequential.

How do I get the parameter object of the query parameter, so that I can pass it without having to know the actual query in the store.find ('modelName', params) / Can i

One way to do this would be the following within the controller:

  var params = {}; ('Query prams') Each (function (param) {params [param] = it. Gate (ultimate);}, this); This.store.find ('widgets', params);  

... but there must be a more beautiful way to do this.

I'm not sure that this is better, but what I am currently doing is the following:

this.store.find ('widget', this.getProperties (this. GetProperties ('queryParams'). QueryParams))

On this controller All query parameters will take and provide them in the model.find method. I'm not sure that this approach has a negative effect, but it is a little more concise than running on each property.


No comments:

Post a Comment