mardi 1 décembre 2015

Alternative to the 'hash parameters' limitation of query-params in link-to helper in Ember

Is there a way to pass a hash from a model as the query params to the link-to helper?

For example, I have a model:

export default DS.Model.extend({
  val1: DS.attr('string'),
  val2: DS.attr('string'),
  asHash: Ember.computed('val1', 'val2', function() {
    'val1': this.get('val1'),
    'val2': this.get('val2'),
  })
});

And in a component I want to use that value like:

<div>
  {{#link-to 'query-page' (query-params model.asHash)}}query{{/link-to}}
</div>

The example above results in an error:

Uncaught Error: Assertion Failed: The query-params helper only accepts hash parameters, e.g. (query-params queryParamPropertyName='foo') as opposed to just (query-params 'foo')

Any ideas on how this can be worked around?




Aucun commentaire:

Enregistrer un commentaire