vendredi 11 mars 2016

Ember select and query parameters. Getting undefined

I'm trying to select an option, and once it's selected, get the value of the object and change the url with that value.

right now, I'm getting undefined in the url:

http://localhost:4200/product?company=undefined

controller:

import Ember from 'ember';

 export default Ember.Controller.extend({
   queryParams: ['company'],
   company: null,
    .......

   actions: {
     selectCompany: function(value) {
     this.set('company', value);
      }
    }

 });

Template:

<select {{ action 'selectCompany' on='change' value=model.value}}>
    {{#each sortedTraitsAsc as |company|}}
       <option value={{trait.id}}>  {{trait.value}}</option>
   {{/each}}
 </select>

Model

  import DS from 'ember-data';

  export default DS.Model.extend({
  value: DS.attr('string')
  });

Aucun commentaire:

Enregistrer un commentaire