2
votes

I want to bind a controller property that contains an ember-data object to a query string param. I'm using 1.6.0-beta.1+canary with the following in my controller.

export
default Ember.Controller.extend({
    queryParams: ['project'],
    project: null
});

I can't find a way to serialize/deserialize the ember-data object (project) to/from the url though. Is it possible yet?

1
Did you happen to find this out?sheldonbaker

1 Answers

1
votes

I'm not sure why but it seems that the ember team don't want to support serialization of query-params. The best suggestion seems to be to do use a computed property like this:

App.MyController = Ember.ObjectController.extend({
  queryParams: ['recordId']
  recordId: null,
  record: function(key, value) {
    if (arguments.length > 1) {
     //handle set by setting recordId
     this.set('recordId', value.get('id'); 
   }
   return this.store.find('record', this.get('recordId'));
  }.property('recordId')
});

It's workable but seems cludgy to say the least...