jeudi 13 avril 2017

Ember js pushObject overriding the array

I am working on Ember.js and i have a select element which is set to send value "onchange" i am receiving the value without any problem .. But i want to save every selection into an array and display it on the fly in labels Here is my template.hbs

<div class="panel-body">
    <div class="form-group">
      <select name="services" id="services" class="form-control" onchange=>
          <option> Select Services </option>
        
          <option value=""></option>
        
      </select>
    </div>
    <div class="form-group">
      
      
        <span class="label label-primary"> </span>
      
    </div>
  </div>

and here is my controller

  actions: {
setValue(ser){
  var selectedService = [];
  this.set('selectedService', ser);
  selectedService.pushObject(ser);

  console.log(selectedService);
}

i tried to log "selectedService[1]" and select two items but it's not working it keeps on overriding the first item :(




Aucun commentaire:

Enregistrer un commentaire